分享

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

 aaie_ 2012-10-20
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;

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多