Solved

Search files in whole HD

Posted on 2001-07-27
4
185 Views
Last Modified: 2010-04-06
How can I do a search for a file in whole hard disk.
thanks a lot.
Headry
0
Comment
Question by:Headry
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6329263
hi,
this will search all drives and return all found .mp3 files into combobox with path:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ComboBox1: TComboBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure GatherFiles(Const Lines: TStrings; Const Dir,Match: String);
var
  Rec: TSearchRec;
  Found: Integer;
Begin
  Found:= FindFirst(Dir+'\'+Match, faAnyFile, Rec);
  While Found = 0 do
  begin
    If (Rec.Attr AND faDirectory) = 0 Then Lines.Add(Dir+'\'+Rec.Name);
    Found := FindNext(Rec);
    Application.processmessages;
  End;
  FindClose(Rec);
  Found:= FindFirst(Dir+'\*.*', faAnyFile, Rec);
  While Found = 0 do
  begin
    If ((Rec.Attr AND faDirectory)>0) AND
       (Rec.Name<>'.') AND
       (Rec.Name<>'..') Then GatherFiles(Lines,Dir+'\'+Rec.Name,Match);
    Found := FindNext(Rec);
  End;
  FindClose(Rec);
End;

procedure TForm1.Button1Click(Sender: TObject);
var
b : byte;
drivenum  : set of 0..25;
driveletter : string;
const
drivetype : array [0..6] of string = ('CD-Rom','Local Drive','Floppy Disk',
'Network Drive','RAM-Disk','Unknown','Unknown');
 begin
  integer(drivenum):=GetLogicalDrives;
   for b := 0 to 25 do
    if b in drivenum then
   begin
    driveLetter:=char(b + ord('A'));
     GatherFiles(ComboBox1.Items,driveletter+':','*.mp3');
     application.processmessages;
      end;
  If ComboBox1.Items.Count>0 Then
   ComboBox1.Text:= ComboBox1.Items[0];
  ShowMessage('Found '+IntToStr(ComboBox1.Items.Count)+' matching files.');
end;

end.



or on the button click can just do
GatherFiles(ComboBox1.Items,'C:','*.dll');
to only search c drive for .dlls for instance.
0
 
LVL 1

Expert Comment

by:trex_fire
ID: 6330345
Never heard of jedi project?

Lot of great code and free, i use it a lot and it solves a lot of problems...  http://www.delphi-jedi.org/

post me if you need any help on that

T-Rex
trex_fire@hotmail.com
0
 

Author Comment

by:Headry
ID: 6330352
thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks!!!
Finaly!
you`re good. For a hobby, you know much!
thanks again!
0
 

Author Comment

by:Headry
ID: 6330360
thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks,thanks!!!
Finaly!
you`re good. For a hobby, you know much!
thanks again!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question