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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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.
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?
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,'Combo box',nil);
h:=FindWindowex(h,0,'Edit' ,nil);
if h<>0 then SendMessage(h,WM_SETTEXT,0 ,Integer(F Name))
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(C Text))
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.h andle,'fin d','','',' ',sw_norma l);
repeat
h:=FindWindow(nil,'Find: All Files');
Application.ProcessMessage s;
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
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,'Combo
h:=FindWindowex(h,0,'Edit'
if h<>0 then SendMessage(h,WM_SETTEXT,0
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'
if h<>0 then SendMessage(h,WM_SETTEXT,0
else showmessage('Error writing Containing Text!');
end;
procedure TForm1.Button1Click(Sender
var h:hwnd;
begin
h:=FindWindow(nil,'Find: All Files');
if h = 0 then shellexecute(application.h
repeat
h:=FindWindow(nil,'Find: All Files');
Application.ProcessMessage
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
ASKER
You deserve some points for this...
....so...
I've posted a followup question for you, which I hope you can answer.
....so...
I've posted a followup question for you, which I hope you can answer.
Just a guess...
TiM.