Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Search files in whole HD

Posted on 2001-07-27
4
Medium Priority
?
194 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 200 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

876 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