線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2229
推到 Plurk!
推到 Facebook!

利用SendMessage傳遞記憶體位址傳送中文或字串

 
mine
中階會員


發表:28
回覆:129
積分:56
註冊:2004-03-31

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-16 09:58:23 IP:61.221.xxx.xxx 未訂閱
程式A
傳送端
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;    const
   WM_TEST=49519;    type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  public
   str:array [0..24] of Char;
  end;    var
  Form1: TForm1;    implementation    {$R *.dfm}    procedure TForm1.Button1Click(Sender: TObject);
var
temp:Thandle;
begin
strcopy(str,pchar(Edit1.text));
SendMessage(HWND_BROADCAST,WM_CMTCCID,Longint(@str),application.Handle);
end;    end.
程式B接收端
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,tlhelp32, ShellAPI, PSAPI;    const
   WM_TEST=49519;    type
  TForm1 = class(TForm)
    Memo1: TMemo;
  private
  public
   procedure Wndproc(var Message:TMessage);override;
  end;    var
  Form1: TForm1;
  str:array[0..24] of char;    implementation    {$R *.dfm}    procedure TForm1.Wndproc(var Message:TMessage);
var
AProcessID,WridCount:DWORD;
gg:longbool;
pt:THandle;
begin
Case Message.Msg of
 WM_TEST:begin
         GetWindowThreadProcessId(Message.LParam, @AProcessID);
         pt:=openprocess(PROCESS_VM_READ,false,AProcessID);//要求打開拜訪行程
         gg:=ReadProcessMemory(pt,Pointer(message.WParam),@str,25,WridCount);//讀取記憶體內容
         Memo1.text:=Memo1.Text (pchar(@str));
         showMessage(inttostr(WridCount));
         showMessage(inttostr(message.lparam));
         ShowMessage(inttostr(longint((Pointer(message.WParam)))));
         end;
end;
inherited Wndproc(Message);
end;
由於內容不多就不再上傳檔案了 搞不懂!搞不懂!永遠都搞不懂!!
系統時間:2024-05-01 3:00:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!