Link to home
Start Free TrialLog in
Avatar of Softtech
Softtech

asked on

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?
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Is there a function called "Find" or "ShellFind" in Shell32.dll?

Just a guess...

TiM.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AttarSoftware
AttarSoftware

Ahhh...  so simple...
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.
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.
Avatar of Softtech

ASKER

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?
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
You deserve some points for this...

....so...

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