我在 Pascal 中覆盖了函数库 kernel32.dll,OpenProcess 函数返回 0。函数 GetLastError() 返回 87 错误,这意味着
ERROR_INVALID_PARAMETER 87 (0x57) 参数不正确。
有什么问题?
Program UODll;
const search_window = 'Ultima Online - xxx (The Abyss)';
function FindWindow(C1, C2: PChar): Longint; external 'FindWindowA@user32.dll stdcall';
function GetWindowThreadProcessId(hWnd: Longint; opt: Word): Word; external 'GetWindowThreadProcessId@user32.dll stdcall';
function OpenProcess(dwDesiredAccess: Word; inherit: Byte; pid: Word): Longint; external 'OpenProcess@kernel32.dll stdcall';
function GetProcessId(proc: Longint): Word; external 'GetProcessId@kernel32.dll stdcall';
function GetLastError(): Word; external 'GetLastError@kernel32.dll stdcall';
var
res, err: Word;
wnd, proc: Longint;
Begin
wnd := Findwindow('', search_window);
if (wnd > 0) then
begin
res := GetWindowThreadProcessId(wnd, res);
proc := OpenProcess($0400,0,res);
err := GetLastError();
writeln(IntToStr(proc));
writeln(IntToStr(err));
end;
End.
我试图使用 LongWord 和 Cardinal,但我有同样的错误。谁能帮助我?) PS 它不是 delphi .. 我不知道这是什么 :) Programm 调用 UOScript