简体   繁体   English

调用CWnd :: InvokeHelper时出现类型不匹配错误

[英]Getting Type Mismatch Error when calling CWnd::InvokeHelper

So I have tried to debug the program and as soon as I get into the Windows API function calls things get a little crazy, plus there isn't much help with debugging those files because I can't change them anyways. 因此,我尝试调试该程序,并且一旦进入Windows API函数调用,事情就会变得有些疯狂,再加上调试这些文件并没有太多帮助,因为无论如何我都无法更改它们。 Basically what I am stuck on is the following two functions that I can change (FYI this is really old code and the program works in 32bit versions but when converted to 64bit this problem occurred): 基本上,我只能更改以下两个函数(仅供参考,这确实是旧代码,并且该程序可以在32位版本中运行,但是在转换为64位时会出现此问题):

void CSalvoPage::AdviseScrollingButtonPanel()
{
    if ( m_SBPCookie == 0 )
    {
        IUnknown * pSinkUnk;
        long * pCookie = &m_SBPCookie;
        m_spSBPControlSink->QueryInterface(IID_IUnknown, (void **) &pSinkUnk);

        if (pSinkUnk != NULL)
        {
            m_SalvoButtons.AddListener(pSinkUnk, pCookie);//here is the problem~~~~
            pSinkUnk->Release();
        }
    }
}

Then we have the AddListener call which does this 然后,我们执行此操作的AddListener调用

void CNvButtonPanel::AddListener(LPUNKNOWN pUnk, long* pCookie)
{
    static BYTE parms[] =
        VTS_UNKNOWN VTS_PI4;
    InvokeHelper(0x16, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         pUnk, pCookie);
}

I know for a fact that the InvokeHelper function throws the exception through debugging. 我知道InvokeHelper函数通过调试抛出异常。 All I seem to understand is that parms[] lets the InvokeHelper know what types of parameters it's getting and how many. 我似乎只了解parms []可以让InvokeHelper知道它要获取的参数类型和数量。 I looked up the definitions and found that in fact 我查看了定义,发现实际上

VTS_UNKNOWN = "\x0D" //IUNKNOWN*

and

VTS_PI4 = "\x43" //a 'long*'

Therefore I am telling the InvokeHelper the correct types of parameters to expect so I don't understand why I get a Type Mismatch Error in a popup window everytime I run the program... Any ideas as to why my InvokeHelper throws the Type Mismatch Error? 因此,我告诉了InvokeHelper期望的参数正确类型,所以我不明白为什么每次运行程序时都会在弹出窗口中收到类型不匹配错误的信息... 关于为什么我的InvokeHelper引发类型不匹配错误的任何想法?

I have tried to look into the InvokeHelper method documentation and it's really confusing... What I do know is that it throws the COleException mentioned in the documentation and the SCODE returned from the Invoke method is -2147352571 我试图查看InvokeHelper方法文档,这确实令人困惑...我知道的是,它抛出了文档中提到的COleException,而从Invoke方法返回的SCODE是-2147352571

[id(22), helpstring("method AddListener")] 
            HRESULT AddListener(
                [in] IUnknown * pUnk,
                [out] IUnknown ** pCookie
                );

I was able to fix the issue by doing what RbMm suggested which was to change the function AddListener and RemoveListener functions to match the types declared in the .idl file. 通过执行RbMm建议,可以更改功能AddListener和RemoveListener函数以匹配.idl文件中声明的类型,从而能够解决此问题。

void AddListener(LPUNKNOWN pUnk, LPUNKNOWN* pCookie);
void RemoveListener(LPUNKNOWN pCookie);

The functions now correctly match the types defined in the .idl file 这些函数现在可以正确匹配.idl文件中定义的类型

[id(22), helpstring("method AddListener")] 
    HRESULT AddListener(
        [in] IUnknown * pUnk,
        [out] IUnknown ** pCookie
        );

[id(23), helpstring("method RemoveListener")] 
    HRESULT RemoveListener(
        [in] IUnknown * pCookie
        );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM