- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi GetWindowHandle
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);
begin
form1.Caption:=inttostr(GetWindowHandle(2888));
end;