WinExec Find Files or Folders?

I would like to call Window 98's "Find Files or Folders" window from a D3 program I am writing.  Can this be done via WinExec()?

Just in case it is not clear what "Find Files or Folders" means...click "Start" > "Find" > "Files or Folders".

Can this Win utility be called from a Delphi app?
SofttechAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
this will call it:

add to uses section ShellAPI


procedure TForm1.Button1Click(Sender: TObject);
begin
shellexecute(application.handle,'find','','','',sw_normal);
end;

Regards Barry
0
 
TimYatesCommented:
Is there a function called "Find" or "ShellFind" in Shell32.dll?

Just a guess...

TiM.
0
 
AttarSoftwareCommented:
Ahhh...  so simple...
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
craig_capelCommented:
Barry..... have you got a list of these shellexecute commands? so far i have seen them for Email, URL, playing winamp.... see loads, but how do you know what commands go here, you must have a reference.... i will glady post some points for you.... :)

Craig C.
0
 
intheCommented:
answering questions all day you just pick these things up..
most shell functions are defined in shellapi.pas
shellexecute(0,'open',....
shellexecute(0,'print',...
shellexecute(0,'find',....

best thing is read the win32.hlp file
and that with the internet you have the biggest reference in front of you.
my advice is save every peice of code you come accross in a code database,one day it will come in handy.
0
 
SofttechAuthor Commented:
Thanks...

Now...would I be pushing my luck if I asked...is there a way to populate the "Find" field automatically? IOW, when the Find dialog appears, the  "Named" field has ".xyz" as the default?
0
 
intheCommented:
haha i knew that you would ask this and im afraid from the shellexecute its not possible. :-(
but there is a way of doing it and you cant tell its not being called from execute method.you can find the window and write directly to the edits with the name of file to find etc.if you know what i mean.
here is teseted example just a button on a form.
if the find has already been called it will write to that one if not it will call find then write to it.:

unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

Procedure FileNamed(FName:string);
var h:hwnd;
begin
h:=FindWindow(nil,'Find: All Files');
setforegroundwindow(h);
h:=getwindow(h,GW_CHILD);
h:=FindWindowex(h,0,'Combobox',nil);
h:=FindWindowex(h,0,'Edit',nil);
if h<>0 then SendMessage(h,WM_SETTEXT,0,Integer(FName))
        else showmessage('Error writing File name!');
end;

Procedure ContainingText(CText : string);
var h:hwnd;
begin
h:=FindWindow(nil,'Find: All Files');
setforegroundwindow(h);
h:=getwindow(h,GW_CHILD);
h:=FindWindowex(h,0,'Edit',nil);
if h<>0 then SendMessage(h,WM_SETTEXT,0,Integer(CText))
        else showmessage('Error writing Containing Text!');
end;

procedure TForm1.Button1Click(Sender: TObject);
var h:hwnd;
begin
h:=FindWindow(nil,'Find: All Files');
if h = 0 then shellexecute(application.handle,'find','','','',sw_normal);
repeat
 h:=FindWindow(nil,'Find: All Files');
 Application.ProcessMessages;
 until h <> 0;
FileNamed('*.Pas');
ContainingText('Procedure');
end;

end.


pushing your luck works sometimes eh :-)
actually i quite like writing stuff like that so i dont mind.

Regards Barry
0
 
SofttechAuthor Commented:
You deserve some points for this...

....so...

I've posted a followup question for you, which I hope you can answer.
0
All Courses

From novice to tech pro — start learning today.