You are on page 1of 2

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/ html/delphivclwin32/SysUtils_TSearchRec.

html Pascal TSearchRec = record Time: Integer; Size: Int64; Attr: Integer; Name: TFileName; ExcludeAttr: Integer; FindHandle: THandle platform; FindData: TWin32FindData platform; end; C++ struct TSearchRec { int Time; Int64 Size; int Attr; TFileName Name; int ExcludeAttr; THandle platform FindHandle; TWin32FindData platform FindData; }; void __fastcall TForm1::Button1Click(TObject *Sender) { TSearchRec sr; int iAttributes = 0; StringGrid1->RowCount = 1; iAttributes |= faReadOnly * CheckBox1->Checked; iAttributes |= faHidden * CheckBox2->Checked; iAttributes |= faSysFile * CheckBox3->Checked; iAttributes |= faVolumeID * CheckBox4->Checked; iAttributes |= faDirectory * CheckBox5->Checked; iAttributes |= faArchive * CheckBox6->Checked; iAttributes |= faAnyFile * CheckBox7->Checked; StringGrid1->RowCount = 0; if (FindFirst(Edit1->Text, iAttributes, sr) == 0) { do { if ((sr.Attr & iAttributes) == sr.Attr) { StringGrid1->RowCount = StringGrid1->RowCount + 1; StringGrid1->Cells[1][StringGrid1->RowCount-1] = sr.Name; StringGrid1->Cells[2][StringGrid1->RowCount-1] = IntToStr(sr.Size); } } while (FindNext(sr) == 0); FindClose(sr); } } procedure TForm1.Button1Click(Sender: TObject); var sr: TSearchRec; FileAttrs: Integer; begin StringGrid1.RowCount := 1; if CheckBox1.Checked then FileAttrs := faReadOnly

else FileAttrs := 0; if CheckBox2.Checked then FileAttrs := FileAttrs + faHidden; if CheckBox3.Checked then FileAttrs := FileAttrs + faSysFile; if CheckBox4.Checked then FileAttrs := FileAttrs + faVolumeID; if CheckBox5.Checked then FileAttrs := FileAttrs + faDirectory; if CheckBox6.Checked then FileAttrs := FileAttrs + faArchive; if CheckBox7.Checked then FileAttrs := FileAttrs + faAnyFile; with StringGrid1 do begin RowCount := 0; if SysUtils.FindFirst(Edit1.Text, FileAttrs, sr) = 0 then begin repeat if (sr.Attr and FileAttrs) = sr.Attr then begin RowCount := RowCount + 1; Cells[1,RowCount-1] := sr.Name; Cells[2,RowCount-1] := IntToStr(sr.Size); end; until FindNext(sr) <> 0; FindClose(sr); end; end; end;

You might also like