Delphi如何获取QQ2010聊天窗口句柄


本文整理自网络,侵删。

  Delphi如何获取QQ2010聊天窗口句柄? unit HKProc; 

interface

uses
Windows, Messages,Dialogs,iniFiles,SysUtils;

var
hNextHookProc: HHook;
procSaveExit: Pointer;

function CBTProc(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
function EnableHotKeyHook: BOOL; export;
function DisableHotKeyHook: BOOL; export;

implementation

function CBTProc(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
p: PCBTActivateStruct;
begin
result:= 0;
If iCode <0 Then
begin
Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);
Exit;
end
else
begin
If iCode = HCBT_ACTIVATE then
begin
p:= PCBTActivateStruct(lParam);
if (p.hWndActive = findwindow( '#32770 ',nil)) then showmessage( 'lkjl ');
end;
end;
end;


function EnableHotKeyHook: BOOL; export;
begin
Result := False;
if hNextHookProc <> 0 then Exit;
hNextHookProc := SetWindowsHookEx(WH_CBT,CBTProc,HInstance,0);
Result := hNextHookProc <> 0;
end;

function DisableHotKeyHook: BOOL; export;
begin
if hNextHookProc <> 0 then
begin
UnhookWindowshookEx(hNextHookProc);
hNextHookProc := 0;
end;
Result := hNextHookProc = 0;
end;

end.
If iCode = HCBT_ACTIVATE then
begin
p:= PCBTActivateStruct(lParam);
p.hWndActive//就是激活窗口的句柄。findwindow( '#32770 ',nil)返回的是QQ聊天窗口的句柄
end;

相关阅读 >>

Delphi内联汇编的一点心得

Delphi 安装fastreport4.8.xx

Delphi 显示简单图形

Delphi idhttp 断开连接/超时读取

Delphi截取字符串 防止中文截断

Delphi word转pdf两种方法

Delphi读取网页源文件和获取字符串

Delphi winapi: movewindow - 改变窗口的位置与大小

Delphi 检测用户超过多长时间没有操作键盘或鼠标

Delphi 16进制字符串转原字符串

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...