Solved

Search for a file (component or API function)

Posted on 1998-12-22
5
169 Views
Last Modified: 2010-04-04
I need a component or API function that can search for a file on local hard drives. I know how to do this non-visually, but I want the Win95/98 animated search icon to appear as the file is being searched for.
Any help appreciated.
0
Comment
Question by:friberg
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:williams2
Comment Utility
This is what you do:

The following example demonstrates using DDE to execute Explorer's
find file dialog. The example opens the dialog in the Directory
"C:\Download".


procedure TForm1.Button1Click(Sender: TObject);
begin
  with TDDEClientConv.Create(Self) do begin
    ConnectMode := ddeManual;
    ServiceApplication := 'explorer.exe';
    SetLink( 'Folders', 'AppProperties');
    OpenLink;
    ExecuteMacro('[FindFolder(, C:\DOWNLOAD)]', False);
    CloseLink;
    Free;
  end;
end;

0
 

Author Comment

by:friberg
Comment Utility
Thanks, but I need to catch the complete path of the file in the application, so that I can store it in a string and use it in the code. And I also need to specify (in the application) which file to search for.
0
 
LVL 4

Accepted Solution

by:
dwwang earned 50 total points
Comment Utility
>>"I know how to do this non-visually"

So it's easy enough, all you need is to put the TAnimate component on your form, select the commonAvi property, set it to aviFindFile.
When you starting to search, set Animate1.active:=true;

Regards,
Wang
0
 
LVL 3

Expert Comment

by:williams2
Comment Utility
Hmmm.. Your question is somehow a bit easy to misunderstand! this is the only API call doing this.

The animated cursor thing just shows you what's is beeing done while it, but if you want it showing while searching, do like Wang shows you to a Form2 while you can set it up as a dialog form showing at screen center.

Then this works perfectly:

procedure FindFilesInDir(var List: TStringList; Directory, SearchName: String);
var
 S: TSearchRec;
 I: Integer;
begin
  I := FindFirst(Directory+'\*.*',faAnyFile,S);
  While I=0 do
  Begin
    If (S.name<>'.') AND (S.Name<>'..') then
    Begin
      if pos(SearchName,S.Name)>0 then List.Add(Directory+'\'+S.Name);
      If (S.Attr AND faDirectory)>0 then
        FindFilesInDir(List,Directory+'\'+S.Name,SearchName);
    End;
    I:= FindNext(S);
  End;
  FindClose(S);
End;

procedure TForm1.Button1Click(Sender: TObject);
var
  List: TStringList;
begin
  List:= TStringList.Create;
  Form2.Show;
  Form2.Animate1.Active:= True;
  FindFilesInDir(List,'C:','.zip');
  Memo1.Lines.AddStrings(List);
  List.free;
  Form2.Animate1.Active:= False;
  Form2.Close;
end;
0
 

Author Comment

by:friberg
Comment Utility
Thanks, I'll try that.

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now