Delphi Tips&Tricks News   Tips   .NET Software   VCL Software   Search   Contacts
Ultimate Pack Special Offer!


Share this page

Follow us
LinkedIn Blogspot Twitter Facebook

Related products
Ultimate Pack  hot!
iGrid Plotter  new!
Image Editor
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET
Print Suite .NET
Gradient Controls .NET  new!

Related links
Win32.hlp online version
MegaDetailed.NET
Delphi to C#

Special
Free Software Promotion
Offers for Resellers

Hobby projects
cdtrrracks.com
books.storrre.com
in3steps.com
sovietphillumeny.com

Recognize whether Word is installed - Files & folders - Tips & Tricks - Greatis Delphi Pages

Use the FindFirst and FindNext functions for searching files in a directory.
Procedure TForm1.Find searches winword.exe file in a directory.


procedure TForm1.Find(Str: string);
var
  MySearch: TSearchRec;
  FindResult: Integer;
begin
  FindResult:=FindFirst(Str+'\winword.exe', 
                        faAnyFile+faHidden+faReadOnly, 
                        MySearch);
  if FindResult=0 then
  begin
    Label2.Caption:=Str+'\'+MySearch.Name;
    Test:=True;
  end
  else
  begin
    FindResult:=FindFirst(Str+'\*.*', 
                          faArchive+faHidden+
                          faAnyFile+faVolumeID+
                          faSysFile+faReadOnly+faDirectory, 
                          MySearch);
    while FindResult=0 do
    begin
      StatusBar1.SimpleText:=Str+'\'+MySearch.Name;
      if (MySearch.Attr=faDirectory) and 
         (MySearch.Name<>'.') and 
         (MySearch.Name<>'..') then
        Find(Str+'\'+MySearch.Name);
      FindResult:=FindNext(MySearch);
    end;
  end;
  FindClose(MySearch);
end;
Related topics
Delete all files within directory
Remove all files from directory
Find out total size of directory

For more
Delphi Help

Download source