本文整理自网络,侵删。
function GetWindowHandle(ProcessId: Cardinal): THandle;var hFound: THandle;
function EnumWindowsProcMy(_hwnd: HWND; ProcessId: Cardinal): BOOL; stdcall;var dwPid: Cardinal;begin GetWindowThreadProcessId(_hwnd, @dwPid);
if ProcessId = dwPid then begin hFound := _hwnd; Result := False; end else Result := True;end;
begin EnumWindows(@EnumWindowsProcMy, LPARAM(ProcessId)); Result := hFound;end;
procedure TForm1.Button1Click(Sender: TObject);beginform1.Caption:=inttostr(GetWindowHandle(2888));end;
相关阅读 >>
Delphi tdirectory.tfilterpredicate
Delphi xe android 程序切换到后台及从后台切换到前台实现
更多相关阅读请进入《Delphi》频道 >>