DLL.pdr内容如下:library QQDll;
uses
windows,messages,
Varunit in 'Varunit.pas';exports
getprocess;end.Varunit.pas内容如下:unit Varunit;interface
uses
windows,messages,sysutils;function getprocess(H:hwnd;I:integer):string;exportimplementationfunction getprocess(H:hwnd;i:integer):string;export;
var
pid:hwnd;
phandle:hwnd;
hp:pointer;
nsize:dword;
l:dword;
begin
nsize := 18;
hp:=allocmem(nsize);
getwindowthreadprocessid(h,@pid);
phandle:= openprocess(process_all_access,false,pid);
readprocessmemory(phandle,pointer(i),hp,nsize,l);
if strpas(hp) = '' then exit;
result := strpas(hp);
end;end.调用DLL的EXE文件内容如下:unit Main;
............
implementationfunction getprocess(h:hwnd;i:integer):string;external 'qqdll.dll';{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
EDIT1.Text := '';
end;procedure TForm1.Button1Click(Sender: TObject);
var
AllStr:string;
hand:hwnd;
begin
hand := findwindow(nil,'Mword');
if hand <> 0 then
begin
AllStr := getprocess(hand,$476E97);
edit1.Text := AllStr;
end;
end;这样应该没有错。但是为什么点按钮后就是不行呢?弹出出错对话框,上面写着:
Project EXE.exe raised exception class EInavalidPointer with message 'Invalid pointer operation'.Process stopped. Use Step or Run to continus.
不知道是什么情况。哪位能帮我看看?
uses
windows,messages,
Varunit in 'Varunit.pas';exports
getprocess;end.Varunit.pas内容如下:unit Varunit;interface
uses
windows,messages,sysutils;function getprocess(H:hwnd;I:integer):string;exportimplementationfunction getprocess(H:hwnd;i:integer):string;export;
var
pid:hwnd;
phandle:hwnd;
hp:pointer;
nsize:dword;
l:dword;
begin
nsize := 18;
hp:=allocmem(nsize);
getwindowthreadprocessid(h,@pid);
phandle:= openprocess(process_all_access,false,pid);
readprocessmemory(phandle,pointer(i),hp,nsize,l);
if strpas(hp) = '' then exit;
result := strpas(hp);
end;end.调用DLL的EXE文件内容如下:unit Main;
............
implementationfunction getprocess(h:hwnd;i:integer):string;external 'qqdll.dll';{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
EDIT1.Text := '';
end;procedure TForm1.Button1Click(Sender: TObject);
var
AllStr:string;
hand:hwnd;
begin
hand := findwindow(nil,'Mword');
if hand <> 0 then
begin
AllStr := getprocess(hand,$476E97);
edit1.Text := AllStr;
end;
end;这样应该没有错。但是为什么点按钮后就是不行呢?弹出出错对话框,上面写着:
Project EXE.exe raised exception class EInavalidPointer with message 'Invalid pointer operation'.Process stopped. Use Step or Run to continus.
不知道是什么情况。哪位能帮我看看?
var
pid: hwnd;
phandle: hwnd;
nsize: DWORD;
l: DWORD;
begin
nsize := 18;
GetWindowThreadProcessid(h,@pid);
phandle := OpenProcess(process_all_access, False, pid);
ReadProcessMemory(phandle, Pointer(i), vData, nsize, l);
end;procedure getprocess(h:hwnd;i:integer;data:pchar);external 'qqdll.dll';procedure TForm1.Button1Click(Sender: TObject);
var
AllStr: string;
hand: hwnd;
begin
hand := findwindow(nil,'Mword');
if hand <> 0 then
begin
SetLength(AllStr, 18); // 分配资源
AllStr := getprocess(hand, $476E97, @AllStr[1]);
edit1.Text := AllStr;
end;
end;
停在 @allstr[1] 这里,显示错误:Too many actual parameters
DLL里面也编译不了。
停在 function getprocess(H:hwnd;I:integer;vData:PChar);export 这里,显示错误:Function needs result type //应该是说函数需要定义类型吧?
->
procedure getprocess(H:hwnd;I:integer;data:PChar);