在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
type function IsMainWindow(AHandle: THandle): Boolean;
begin
Result :=(GetWindow(AHandle, GW_OWNER) = 0) and (IsWindowVisible(AHandle));
end;{ IsMainWindow }
function fFindMainWindow(hWnd: THandle; lParam: PMainWindow): BOOL; stdcall;
var
vProcessID: THandle;
begin
GetWindowThreadProcessId(hWnd, vProcessID);
if (lParam^.ProcessID = vProcessID) and IsMainWindow(hWnd) then
begin
lParam^.MainWindow := hWnd;
Result := False;
end else Result := True;
end;
function FindMainWindow(AProcessID: THandle): THandle;
var
vMainWindow: TMainWindow;
begin
vMainWindow.ProcessID := AProcessID;
vMainWindow.MainWindow := 0;
EnumWindows(@fFindMainWindow, Integer(@vMainWindow));
Result := vMainWindow.MainWindow;
end;{ FindMainWindow }
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := Format('Application.Handle: %d, FindMainWindow(): %d',[
Application.Handle, FindMainWindow(GetCurrentProcessId)]);
end;
http://blog.csdn.net/zswang/article/details/1598516 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论