若是查找子窗体就还用用:
FindWindowEx( Parent: HWND; {a handle to a parent window}
Child: HWND; {a handle to a child window}
ClassName: PChar; {a pointer to a null terminated class name string}
WindowName: PChar {a pointer to a null terminated window name string}
): HWND;
procedure TForm1.Button1Click(Sender: TObject);
var
AHwnd: HWND;
WindowText: array[0..255] of char;
begin
AHwnd:= FindWindow('AClass',nil);
{ find a TEdit child window }
AHwnd:=FindWindowEx(AHwnd, 0, 'TEdit',nil);
GetWindowText(AHwnd, WindowText, 255);
Label1.Caption:=WindowText;
end;
Syntax
FindWindow(
lpClassName: PChar; {a pointer to a null terminated class name string}
lpWindowName: PChar {a pointer to a null terminated window name string}
): HWND; {returns a handle to a window}
example:
//the window explorer program must be running in a non-minimized state before
//this example will work
procedure TForm1.Button1Click(Sender: TObject);
var
TheWindow: HWND;
begin
//find a handle to the Windows Explorer window
Thewindow := FindWindow('ExplorerWClass',nil);
//bring it to the top
BringWindowToTop(TheWindow);
end;
该函数可对窗口类进行查找,如成功则返回窗口句柄。
参数:1.lpclassName:类名;可通过winsight32来查找。
2.lpwindowname:标题;
for example:
hWnd:THandle;
hWnd:=FindWindow(nil,windowsname);
if hWnd<>0 then
......
else
......