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 access技巧集

Delphi二分查找算法(预排序数组的查找)

Delphi中如何向某个ip不间断的发送数据

我的Delphi开发经验谈

floattostr 将“浮点型”转换成“字符型”

Delphi 获取按键键值

Delphi firedac 下的 sqlite [11] - 关于批量提交 sql 命令的测试

Delphi tnethttpcleint提交json串

Delphi 调用win32 api操作串口

Delphi中inputbox 和inputquery 函数的使用

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



打赏

取消

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

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

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

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

评论

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