本文整理自网络,侵删。
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 vcl 在trichedit控件中设置wordwrap属性后无法自动换行的问题
Delphi fmx 获取系统版本 android ios通用
更多相关阅读请进入《Delphi》频道 >>