Solved

Search files in whole HD

Posted on 2001-07-27
4
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

636 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