首页  编辑  

挂接桌面窗口wndproc

Tags: /超级猛料/OS.操作系统/桌面/   Date Created:

我是着帮你用修改DeskTopWindow的窗口过程。但没成功。

OldWndProc: function(h: hwnd; m: tmsg; w: wparam; l: lparam): integer; stdcall;

function NewWndProc(h: hwnd; m: tmsg; w: wparam; l: lparam): integer; stdcall;

var

 hdc: Integer;

begin

 Result := OldWndProc(h,m,w,l);

 if h=WM_PAINT then

   begin

   hdc := GetDC(h);

   Rectangle(hdc,100,100,300,300);

   ReleaseDC(h,hdc);

   end;

end;

procedure TForm1.FormCreate(Sender: TObject);

var

 hwnd: Integer;

 retv: Integer;

begin

 hwnd := GetDeskTopWindow;

 OldWndProc := Pointer(GetWindowLong(hwnd,GWL_WNDPROC));

 retv := SetWindowLong(hwnd,GWL_WNDPROC,Integer(@NewWndProc));

end;  //retv 老是为零

procedure TForm1.FormDestroy(Sender: TObject);

var

 hwnd: Integer;

 retv: Integer;

begin

 hwnd := GetDeskTopWindow;

 retv := SetWindowLong(hwnd,GWL_WNDPROC,Integer(@OldWndProc));

end;