使用WH_GETMESSAGE挂钩时为什么WM_CHAR消息被发送两次到某些应用程序? [英] Why the WM_CHAR message is being posted twice to certain applications when using a WH_GETMESSAGE hook?

查看:102
本文介绍了使用WH_GETMESSAGE挂钩时为什么WM_CHAR消息被发送两次到某些应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个代码有什么问题。它在记事本,Iexplorer,文件夹/文件名,Windows资源管理器地址栏中按预期工作,但不在wordpad,firefox,adobe reader中。



if(msg-> message == WM_CHAR)......部分代码执行两次或三次,即使使用WM_LBUTTONDBLCLK消息。为什么这部分在某些应用程序中重复。根据此代码messagebox func应执行一次。



What is the problem with this code.It's working as expected in notepad,Iexplorer,folder/file names,windows explorer address bar,but not in wordpad,firefox,adobe reader.

if(msg->message==WM_CHAR)...... part of code executing twice or thrice,even with WM_LBUTTONDBLCLK message.Why this part repeating in some applications.according to this code messagebox func should execute once.

LRESULT CALLBACK procCharMsg(int nCode,WPARAM wParam, LPARAM lParam)
{
    MSG *msg;    
    HWND ctrHwnd = NULL;

    if(nCode >=0 && nCode == HC_ACTION)     
    {
        msg=(MSG *)lParam;          
        if(msg->message==WM_CHAR)           
        {
            ctrHwnd = msg->hwnd;

            wchar_t szBuff[64];
            wsprintf(szBuff, L"%p", ctrHwnd);
            MessageBox(NULL, szBuff, L"Title", MB_OK);

        }
    }
        return CallNextHookEx(hkKey,nCode,wParam,lParam);//passing this message to target application
}





我尝试了什么:



无法解决问题。所以没有尝试过。



What I have tried:

can't catch problem.so nothing tried.

推荐答案

失败者有一些共同之处,他们都是恶意木马的目标
The ones that fail have something in common they are all targets of malicious trojans
wordpad,firefox,adobe reader



猜测他们有保护方案可以完全停止你想要做的事情。


At a guess they have protection schemes to stop exactly what you are trying to do.


这篇关于使用WH_GETMESSAGE挂钩时为什么WM_CHAR消息被发送两次到某些应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆