Edo082297
asked on
ShellExecute Windows' Find In Files
Howdy
I want to know how to ShellExecute a Windows "Find In Files" dialog, optionally loading it with all it's constituent goodies along the way (i.e. 'file types', 'date created', 'containing keywords' from the advanced tab, etc.).
Lucky for you, I don't need to access the results! I just need to set it up for my users.
Fond Regards,
Edo
I want to know how to ShellExecute a Windows "Find In Files" dialog, optionally loading it with all it's constituent goodies along the way (i.e. 'file types', 'date created', 'containing keywords' from the advanced tab, etc.).
Lucky for you, I don't need to access the results! I just need to set it up for my users.
Fond Regards,
Edo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
unit FindDialogs;
{************************* ********** ********** ********** ***}
{ }
{ TFindFilesDialog & TFindComputerDialog Unit }
{ Copyright ?999 Workshell Software. }
{ }
{ Version 1.0 }
{ }
{ }
{ Web -> http://www.workshell.uni.cc/ }
{ E - Mail -> finddlgs@kinsella.u-net.co m }
{ }
{************************* ********** ********** ********** ***}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ShlObj;
type
TFindFilesDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
type
TFindComputerDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
procedure Register;
implementation
function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 90;
function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 91;
function TFindFilesDialog.Execute: Boolean;
begin
Result := SHFindFiles(nil,nil);
end;
function TFindFilesDialog.ExecuteEx (pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
begin
Result := SHFindFiles(pidlRoot,pidlS avedSearch );
end;
function TFindComputerDialog.Execut e: Boolean;
begin
Result := SHFindComputer(nil,nil);
end;
function TFindComputerDialog.Execut eEx(pidlRo ot, pidlSavedSearch: PItemIDList): Boolean;
begin
Result := SHFindComputer(pidlRoot,pi dlSavedSea rch);
end;
procedure Register;
begin
RegisterComponents('Dialog s', [TFindFilesDialog,TFindCom puterDialo g]);
end;
end.
good luck
hubdog
{*************************
{ }
{ TFindFilesDialog & TFindComputerDialog Unit }
{ Copyright ?999 Workshell Software. }
{ }
{ Version 1.0 }
{ }
{ }
{ Web -> http://www.workshell.uni.cc/ }
{ E - Mail -> finddlgs@kinsella.u-net.co
{ }
{*************************
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ShlObj;
type
TFindFilesDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
type
TFindComputerDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
procedure Register;
implementation
function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 90;
function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 91;
function TFindFilesDialog.Execute: Boolean;
begin
Result := SHFindFiles(nil,nil);
end;
function TFindFilesDialog.ExecuteEx
begin
Result := SHFindFiles(pidlRoot,pidlS
end;
function TFindComputerDialog.Execut
begin
Result := SHFindComputer(nil,nil);
end;
function TFindComputerDialog.Execut
begin
Result := SHFindComputer(pidlRoot,pi
end;
procedure Register;
begin
RegisterComponents('Dialog
end;
end.
good luck
hubdog
unit FindDialogs;
{************************* ********** ********** ********** ***}
{ }
{ TFindFilesDialog & TFindComputerDialog Unit }
{ Copyright ?999 Workshell Software. }
{ }
{ Version 1.0 }
{ }
{ }
{ Web -> http://www.workshell.uni.cc/ }
{ E - Mail -> finddlgs@kinsella.u-net.co m }
{ }
{************************* ********** ********** ********** ***}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ShlObj;
type
TFindFilesDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
type
TFindComputerDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
procedure Register;
implementation
function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 90;
function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 91;
function TFindFilesDialog.Execute: Boolean;
begin
Result := SHFindFiles(nil,nil);
end;
function TFindFilesDialog.ExecuteEx (pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
begin
Result := SHFindFiles(pidlRoot,pidlS avedSearch );
end;
function TFindComputerDialog.Execut e: Boolean;
begin
Result := SHFindComputer(nil,nil);
end;
function TFindComputerDialog.Execut eEx(pidlRo ot, pidlSavedSearch: PItemIDList): Boolean;
begin
Result := SHFindComputer(pidlRoot,pi dlSavedSea rch);
end;
procedure Register;
begin
RegisterComponents('Dialog s', [TFindFilesDialog,TFindCom puterDialo g]);
end;
end.
good luck
hubdog
{*************************
{ }
{ TFindFilesDialog & TFindComputerDialog Unit }
{ Copyright ?999 Workshell Software. }
{ }
{ Version 1.0 }
{ }
{ }
{ Web -> http://www.workshell.uni.cc/ }
{ E - Mail -> finddlgs@kinsella.u-net.co
{ }
{*************************
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ShlObj;
type
TFindFilesDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
type
TFindComputerDialog = class(TComponent)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
function Execute: Boolean;
function ExecuteEx(pidlRoot, pidlSavedSearch: PItemIDList): Boolean;
published
{ Published declarations }
end;
procedure Register;
implementation
function SHFindFiles(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 90;
function SHFindComputer(pidlRoot: PItemIDList; pidlSavedSearch: PItemIDList): Boolean;
stdcall; external 'Shell32.dll' index 91;
function TFindFilesDialog.Execute: Boolean;
begin
Result := SHFindFiles(nil,nil);
end;
function TFindFilesDialog.ExecuteEx
begin
Result := SHFindFiles(pidlRoot,pidlS
end;
function TFindComputerDialog.Execut
begin
Result := SHFindComputer(nil,nil);
end;
function TFindComputerDialog.Execut
begin
Result := SHFindComputer(pidlRoot,pi
end;
procedure Register;
begin
RegisterComponents('Dialog
end;
end.
good luck
hubdog
I think that is what you need .
Listening
doesnt that component just do same as this:
shellexecute(handle,'find' ,'','','', sw_normal) ;
how to load all the "filename", "text to find" etc with this component?
shellexecute(handle,'find'
how to load all the "filename", "text to find" etc with this component?
sorry,I find I am stupid.
I didn't read the question carefully.
hubdog
I didn't read the question carefully.
hubdog
ASKER
Hey Inthe
The code doesn't really work -- it gets stuck ad infinitum in the repeat...until loop. It also doesn't write to the windows. I will play around with it and see if I can get it to work. There were also compilation hints (unnecessary variables declared).
I'm afraid I have to score this as average; it's not up to your usually very high standards (we worked on the math parser a couple of years ago, remember?).
Fond Regards, buddy.
Edo
PS I would have rejected this answer and posted this as a comment but EE seems to have changed their policy in this regard...
The code doesn't really work -- it gets stuck ad infinitum in the repeat...until loop. It also doesn't write to the windows. I will play around with it and see if I can get it to work. There were also compilation hints (unnecessary variables declared).
I'm afraid I have to score this as average; it's not up to your usually very high standards (we worked on the math parser a couple of years ago, remember?).
Fond Regards, buddy.
Edo
PS I would have rejected this answer and posted this as a comment but EE seems to have changed their policy in this regard...
i know im sorry its pretty buggy ;~(
you should have been able to just reject it ..
maybe it is possible to execute a saved find ..
(do a find then do "file" - "save search" on the menu..
you should have been able to just reject it ..
maybe it is possible to execute a saved find ..
(do a find then do "file" - "save search" on the menu..
hi,friends
I guess the better method of setuping the options of search file dialog maybe uses interface ISearchCommandExt imported from microsoft shell controls and automation type library.But when I use cosearchcommand.create to get the interface,there is a error message "class not registered".:(
I don't know how to make it work.But maybe someone can do it .
good luck
hubdog
I guess the better method of setuping the options of search file dialog maybe uses interface ISearchCommandExt imported from microsoft shell controls and automation type library.But when I use cosearchcommand.create to get the interface,there is a error message "class not registered".:(
I don't know how to make it work.But maybe someone can do it .
good luck
hubdog
(fdir dont work though i spent ages on this before with no success so hope someone else has an idea.
Procedure DoFind(FName,FText,FDir:St
var
h,Eh,Eh2,cbh,Ih,Bh,wh,wh1,
begin {get a instance of find or start one}
wh:= FindWindow('#32770','Find:
if wh = 0 then shellexecute(application.h
repeat {tests to get some time mainly and check if window exists}
wh:= FindWindow('#32770',nil);
wh1:=getwindow(wh,GW_CHILD
cbh:=FindWindowex(h,0,'But
wh2:=FindWindowex(wh1,0,'C
wh3:=FindWindowex(wh2,0,'C
wh4:=FindWindowex(wh3,0,'E
Application.ProcessMessage
until wh4 <> 0;
h:= FindWindow('#32770',nil);
Wh1:=getwindow(h,GW_CHILD)
CBh:=FindWindowex(Wh1,0,'C
Eh:=FindWindowex(CBh,0,'Ed
if Eh<>0 then SendMessage(Eh,WM_SETTEXT,
else showmessage('Error writing File name!');
Eh2:=FindWindowex(Wh1,0,'E
if Eh2<>0 then SendMessage(Eh2,WM_SETTEXT
else showmessage('Error writing Containing Text!');
Wh2:=FindWindowex(Wh1,0,'C
Wh3:=FindWindowex(Wh2,0,'C
SendMessage(Wh3,WM_RBUTTON
SendMessage(Wh3,WM_KEYDOWN
SendMessage(Wh3,WM_COMMAND
Wh4:=FindWindowex(Wh3,0,'E
if Wh4<>0 then begin
SendMessage(Wh4,WM_SETTEXT
SendMessage(Wh4,WM_KEYUP,0
SendMessage(Wh4,WM_RBUTTON
end
else showmessage('Error writing File name!');
Ih:=FindWindowex(Wh1,0,'Bu
if FCheck = TRUE then
SendMessage(Ih,BM_SETCHECK
else
SendMessage(Ih,BM_SETCHECK
Bh:=FindWindowex(Wh,0,'But
if Bh<>0 then begin
SendMessage(Bh,WM_LBUTTOND
SendMessage(Bh,WM_LBUTTONU
end
else showmessage('Error Doing Find!');
end;
procedure TForm1.Button1Click(Sender
begin
DoFind('*.pas','Procedure'
end;