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