Delphi 用 CreateOleObject 创建自动化对象,工程选 Win64 目标平台,需先注册 DLL。
// 需先注册:管理员 + 64位 regsvr32 注册 x64Game-Plug.dll
// 工程 -> 目标平台 选 64 位(Win64),uses ComObj, ActiveX
uses ComObj, ActiveX;
var
plug: OleVariant;
hwnd: Int64;
pid: Integer;
title: WideString;
begin
CoInitialize(nil);
try
plug := CreateOleObject('x64Game.Plug');
// 收费命令先授权:plug.SetUsername('U12-XXXXXXXXXXXXXXXX');
hwnd := plug.FindWindow('', '记事本');
pid := plug.GetWindowProcessId(hwnd);
title := plug.GetWindowTitle(hwnd);
Writeln('hwnd = ', hwnd, ' pid = ', pid, ' title = ', title);
finally
plug := Unassigned;
CoUninitialize;
end;
end.