error C2440: 'function' : cannot convert from 'const IID' to 'DWORD'

我与影子孤独终老i 提交于 2019-12-02 05:13:35

From guiddef.h:

#ifndef _REFIID_DEFINED
#define _REFIID_DEFINED
#ifdef __cplusplus
#define REFIID const IID &
#else
#define REFIID const IID * __MIDL_CONST
#endif
#endif

#ifndef _REFCLSID_DEFINED
#define _REFCLSID_DEFINED
#ifdef __cplusplus
#define REFCLSID const IID &
#else
#define REFCLSID const IID * __MIDL_CONST
#endif
#endif

In other words, in C++, those two are references, and in C, they are pointers. You need to use:

ICLRRuntimeHost *host = NULL;
HRESULT result = CorBindToRuntime(NULL, L"wks", &CLSID_CLRRuntimeHost,
    &IID_ICLRRuntimeHost, (PVOID*)&host);

The last parameter of CorBindToRuntime is defined as LPVOID*, not PVOID*. Maybe thats the problem?

HRESULT CorBindToRuntime (
        [in]  LPCWSTR     pwszVersion, 
        [in]  LPCWSTR     pwszBuildFlavor, 
        [in]  REFCLSID    rclsid, 
        [in]  REFIID      riid, 
        [out] LPVOID FAR  *ppv
);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!