取QQ宠物状态...内存操作
//主程序
unit QQPetMain;
inte易做图ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,QQPetUnt, ScktComp;type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation
const
Hungry:DWORD=$004988FC; //内存地址
Clean:DWORD=$004988FE; //内存地址
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
QQPetHungry:string;// 饥饿度
QQPetClean:string;// 清洁
// QQPetHealth:string;//健康
// QQPetMood:string;//心情begin
QQPetHungry:=GetQQPetValue($004988FC);
if QQPetHungry <> then label2.Caption :=QQPetHungry;QQPetClean:=GetQQPetValue($004988FE);
if QQPetClean <> then label4.Caption :=QQPetClean;
end;//QQPetUnt单元
unit QQPetUnt;
inte易做图ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;function GetQQPetValue(MemoryValue:DWORD):String;
implementation
type
TByteArray = array[1..$FFFF] of Byte;
PWord = ^Word;
function GetQQPetValue(MemoryValue:DWORD):String;
var
WinHwnd:hwnd;
h:THandle;
pid:DWORD;
tt:Cardinal;
Buffer:TByteArray;
i:integer;
begin
WinHwnd:=FindWindow(nil,QQPet客户端2.0);
if WinHwnd <> 0 then
begin
GetwindowThreadprocessID(WinHwnd,@pid);
h:=Openprocess(PROCESS_ALL_ACCESS,FALSE,pid);
if h <> 0 then
begin
ReadProcessMemory(h,pointer(MemoryValue),pointer(@(buffer[1])),4,tt);
i:= PWord(@(Buffer[1]))^ ;
Result:=inttostr(i);
closeHandle(h);
end else
begin
Result:=;
end;
end;
end;
end.
补充:综合编程 , 安全编程 ,