在qq的聊天窗口,当按下"发送"按钮之前,执行一段我的代码 
希望能用全局消息钩子加子类化函数实现 
WH_CALLWNDPROC setwindowslong 
因为,用全局钩子消息,我已会 我在学子类化函数的用法? library TmHook; uses 
  SysUtils, 
  Classes, 
  Windows, 
  Messages, 
  CommCtrl; 
var 
  hhook: Windows.HHOOK; 
  hwndListView: HWND; 
  na:array[0..300] of char; 
  oldWndProc: Integer; 
{$R *.res} 
function WindowProc(hwnd: HWND; msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall; 
  begin 
  case Msg of 
    WM_LBUTTONDOWN: 
    MessageBox(hwndListView,'你好!','提示',MB_OK); 
  end; 
  Result := CallWindowProc(TFNWndProc(oldWndProc), hwnd, msg, wp, lp); 
end; 
function TmHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer; stdcall; 
var 
  cwp: PCwpStruct; 
  m:TPoint; 
begin 
  Result := 0; 
  if (nCode < 0) then 
  begin 
    Result := CallNextHookEx(hhook, nCode, wParam, lParam); 
    exit; 
  end; 
  cwp := PCwpStruct(lParam); 
  if cwp^.message <> WM_COMMAND then 
  begin 
    Result := CallNextHookEx(hhook, nCode, wParam, lParam); 
    exit; 
  end; 
  GetCursorPos(m); 
  GetWindowText(WindowFromPoint(m),na,299); 
  if lstrcmpi('发送(S)',na) <>0 then 
  begin 
    Result := CallNextHookEx(hhook, nCode, wParam, lParam); 
    exit; 
  end; 
  hwndListView:=WindowFromPoint(m); 
  oldWndProc := SetWindowLong(hwndListView, GWL_WNDPROC, Integer(@WindowProc)); 
  end; 
procedure Hook(bEnable: Boolean); stdcall; export; 
begin 
  if bEnable then 
  begin 
    if hhook = 0 then 
    begin 
      hhook := SetWindowsHookEx(WH_CALLWNDPROC, TmHookProc, HInstance, 0); 
    end; 
  end 
  else 
  begin 
    if hhook <> 0 then 
    begin 
      UnhookWindowsHookEx(hhook); 
      hhook := 0; 
    end; 
  end; 
end; 
exports 
  Hook; 
begin 
  hhook := 0; 
  hwndListView := 0; 
  oldWndProc:=0; 
end. 
到底哪里错了,一运行,qq就自动关闭?? 
 
 
 

解决方案 »

  1.   

    if lstrcmpi('发送(S)',na) <>0 then 
    这个名称是用spy取到的,我也比对过它的句柄是正确的.
      

  2.   

    个人不建议对QQ之类的用这类初级的方式去做什么手脚.Tencent对于这些方面还是做了大量的防范工作的,你可以替换WNDPROC,它自己也可以替换回来,它还有监视线程在工作.而且有很多地址也难免它不使用伪装,甚至不惜牺牲自己.
      

  3.   

    按钮子类化存在问题,并不表示Edit就不能子类化了不是么?
      

  4.   

    http://topic.csdn.net/u/20081118/16/2fb814e9-76af-4883-8e81-9b599bb83ebc.html?seed=1656828274