在 WH_CBT 回调中将 lpcs->lpszName 与其他值如“OLEChannelWnd”进行比较时出现问题

如何解决在 WH_CBT 回调中将 lpcs->lpszName 与其他值如“OLEChannelWnd”进行比较时出现问题

以下是我的 WH_CBT 回调代码。我试图忽略 Outlook 中超链接的任何点击。当我单击 Outlook 中的超链接时,我收到一个消息框:

image

但是当我在没有 1 条件的回调中返回 if 时,它工作正常。

LRESULT __declspec(dllexport)__stdcall  CALLBACK GetCBTProc(int nCode,WParaM wParam,LParaM lParam)
{

    HRESULT hResult;
    

    if (nCode < 0)
        CallNextHookEx(hkb,nCode,wParam,lParam);

    HWND parentWin;
    DWORD ChiledThreadID;
    DWORD parentProcessID = 0;
    std::ostringstream streamcb;
    DWORD xx = (DWORD)15028;
    HWND hCurrWnd;

    TCHAR  clsName_v[22];
    TCHAR  className[22]="OleMainThreadWndClass";
    LPCSTR oleName2 = _T("OLEChannelWnd");
    int number;
    f1 = fopen("C:\\Log\\report.txt","a+");
    if (nCode == HCBT_CREATEWND)
    {
        hCurrWnd = (HWND)wParam;
        parentWin = GetAncestor(hCurrWnd,GA_ROOT);
        ChiledThreadID = GetwindowThreadProcessId(parentWin,&parentProcessID);
        if (parentProcessID == xx)
        {
            writetofile("HCBT_CREATEWND",15,f1);

            CBT_CREATEWNDA* cw = (CBT_CREATEWNDA*)lParam;
            CREATESTRUCTA* lpcs = (CREATESTRUCTA*)cw->lpcs;

            number = GetClassName(hCurrWnd,clsName_v,22);
            writetofile(clsName_v,number,f1);

            if (lpcs->lpszName)
            {
                if (CompareString(LOCALE_SYstem_DEFAULT,lpcs->lpszName,-1,_T("OLEChannelWnd"),13) == CSTR_EQUAL)
                {
                    return 1;
                }
            }
        }
    }
    fclose(f1);

    LRESULT RetVal = CallNextHookEx(hkb,lParam);

    return  RetVal;

}

解决方法

您的代码缺少两个 *{ font-family: Arial,"Helvetica Neue",Helvetica,sans-serif; font-size: normal; line-height: normal; } /* Generic Styling,for Desktops/Laptops note: the default HTML contains class="topTdStyle" which may be useful. */ table { width: auto; border-collapse: collapse; } td,{ padding: 6px; border: 1px outset #fff; text-align: left; white-space: nowrap; /*creates scrollbar on iPads */ } /*tr { border: 0px outset #fff; }*/ div,table,tbody { border: none !important; } /* Max width before this PARTICULAR table gets nasty This query will take effect for any screen smaller than 760px and also iPads specifically. */ @media only screen and (max-width: 760px),(min-device-width: 768px) and (max-device-width: 1024px) { /* tr:nth-of-type(odd) { background: #f2f2f2; }*/ /* Force table to not be like tables anymore */ table,thead,tbody,th,td,tr { display: block; } /* Hide table headers (but not display: none;,for accessibility) */ thead tr { position: absolute; top: -9999px; left: -9999px; } tr:first-child { display: none; } tr { border: 1px outset #fff; } td { /* Behave like a "row" */ border: none; /*border-bottom: 1px solid #eee; */ position: relative; padding-left: 50%; white-space: normal !important; } td:before { /* Now like a table header */ position: absolute; /* Top/left values mimic padding */ top: 6px; left: 6px; width: 45%; padding-right: 10px; white-space: nowrap; } /* Label the data */ td:nth-of-type(1):before { content: "Event"; } /*used to be "Event"*/ td:nth-of-type(2):before { content: "Time"; } td:nth-of-type(3):before { content: "Standard"; } td:nth-of-type(4):before { content: "P/F/T"; } td:nth-of-type(5):before { content: "Athlete"; } td:nth-of-type(6):before { content: "Age at Meet"; } td:nth-of-type(7):before { content: "Swim Date"; } td:nth-of-type(8):before { content: "Meet Name"; } } 语句,一个在 return 上,一个在回调的末尾。因此,除非输入字符串符合您的条件,否则回调的返回值是不确定。您的编译器应该警告您第二个缺失的 CallNextHookEx()。具有非 return 返回类型的函数必须以 void 语句退出。

试试这个:

return <value>;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?