Delphi有封装的很好的WindowsAPI,直接调用即可,大体上和C++差不多,有些地方需要额外处理。
给出一个实例:
var
g_process: THandle;
procedure initGlobal();
begin
var
g_handle: HWND;
g_handle := FindWindow('clsName', 'name');
if g_handle <> 0 then
begin
var
pid: DWORD;
GetWindowThreadProcessId(g_handle, @pid);
if pid > 0 then
begin
g_process := OpenProcess(PROCESS_ALL_ACCESS, False, pid);
end;
end;
end;
在object pascal中,@是取地址,和FB一样,和C/Cpp中&作用相当。