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就自动关闭??
我在学子类化,这段代码测试了很久,都没有找出原因?
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就自动关闭??
我在学子类化,这段代码测试了很久,都没有找出原因?
解决方案 »
- 数据库判断的问题呢,高手们,帮帮忙,几天了~~~
- 请问类里的属性(property)设置default时出错是什么问题?谢谢
- 调查问卷:请问大家所在的公司有用C/S三层结构的吗?
- 如何用dbexpress 远程连接interbase数据库..............难啊
- Form1.Canvas.Brush.Color:=$00000000+i*$100;
- 怎样将一个表中的全部数据追加到别一个表的后面????在线
- 关于ado在dbgrid中的显示问题?
- 如何遍历一个目录下的文件(不包括子目录)
- 关于DELPHI和VC互调DLL的问题。
- 5-10-2。。。怎么补足2位,补足加0,批量改成 05-10-02
- 500分求关于子类化的代码?
- 子类化
etomahawk,你的意思是说,qq2008测试我上面的代码一切正常吗?
其次,你应该用Spy++先看一下,貌似新的QQ的聊天窗体都是全部自绘的(所以才那么好看),按钮根本没有句柄
GetWindowText(WindowFromPoint(m),na,299);
if lstrcmpi('发送(S)',na) <>0 then
用这种方法好像失去了钩住WM_COMMAND的意义!建议更换钩子类型。如果楼主可以提供一个编程环境,5分钟内解决你的问题,而且是无DLL的钩子。你不能,所以我再次路过...
本想得到三种不同风格的代码,让我推敲.用这种方法好像失去了钩住WM_COMMAND的意义!建议更换钩子类型。
更换钩子类型可以,但一定要子类化,我就学它吗?