怎样调用Window下的“搜索文件或文件夹”(100分)

  • 主题发起人 主题发起人 askyer
  • 开始时间 开始时间
A

askyer

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样调用Window下的“搜索文件或文件夹”,给定特定字符串"abc",文件夹如"c:/wint"
若查找成功报文件名,否则返回0
 
program Project1;

uses windows;

const
WM_CLOSE = $0010;
SW_SHOW = $5;
type
tagMSG = packed record
hwnd: HWND;
message: UINT;
wParam: WPARAM;
lParam: LPARAM;
time: DWORD;
pt: TPoint;
end;

var
h: hwnd;
w: hwnd;
bExit: boolean;
aMessage: TMsg;

function DialogProc(h: hwnd; uMsg: UINT; wParam: wParam; lParam: LPARAM): DWORD; stdcall;
begin
case umsg of
wm_close:
if MessageBox(h, 'Close this Window?', 'Confirm', MB_OKCANCEL+MB_ICONINFORMATION) = IDOK then
begin
DestroyWindow(h);
bExit := True;
end;
else
Result := 0;
end;
end;

begin
h := LoadLibrary('shell32.dll');
bExit := False;
if h = 0 then exit;
w := CreateDialog(h, PAnsiChar(1007), 0, @DialogProc);
FreeLibrary(h);
if w=0 then exit;
ShowWindow(W, SW_SHOW);
while not bExit do
begin
GetMessage(aMessage, 0, 0, 0);
TranslateMessage(amessage);
DispatchMessage(aMessage);
end;
end.

****************
procedure TForm1.Button2Click(Sender: TObject);
function dlgpro(dlghandle:hwnd;dlgmsg:uint;dlgwp:wparam;dlglp:lparam):boolean;stdcall;
var
adc:hdc;
arect:trect;
agdiobj:hgdiobj;
p:PAINTSTRUCT;
begin
case dlgmsg of
wm_initdialog:
begin
result:=true;
end;
wm_paint:
begin
BeginPaint(dlghandle,p);
agdiobj:=getstockobject(black_brush);
fillrect(p.hdc,p.rcPaint,agdiobj);
EndPaint(dlghandle,p);
end;
else
Result:=0;
end;
end;
var
ainstance,ret:thandle;
begin
ainstance:=loadlibrary('comdlg32.dll');
if ainstance <> 0 then begin
ret:=createdialog(ainstance,MAKEINTRESOURCE(1547),application.handle,@dlgpro);
if ret=0 then showmessage('Create dialog failed !');
freelibrary(ainstance);
end
else showmessage('Load library failed !');
end;


SearchPath() API
 

Similar threads

回复
0
查看
1K
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部