我知道VC++6.0是一种非常古老的语言,但是我别无选择,我只是在维护一个现有的程序,并且我遇到了这个错误。
Unhandled exception in Assess.exe (KERNELBASE.DLL): 0xE06D7363: Microsoft C++ Exception
以下是我的代码
HRESULT hr = CoInitialize(NULL);
// Create the interface pointer.
IModulePtr pI(__uuidof(RPTAModuleInterface)); //the error is here
在调试并使用 f11
后,程序进入 COMIP.H
,以下是代码:
explicit _com_ptr_t(const CLSID& clsid, IUnknown* pOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) throw(_com_error)
: m_pInterface(NULL)
{
HRESULT hr = CreateInstance(clsid, pOuter, dwClsContext);
//the program goes to CreateInstance Method
if (FAILED(hr) && (hr != E_NOINTERFACE)) {
_com_issue_error(hr);
//the program goes here and show the error msg
}
}
这里是CreateInstance
函数。
HRESULT CreateInstance(const CLSID& rclsid, IUnknown* pOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) throw()
{
HRESULT hr;
_Release();
if (dwClsContext & (CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER)) {
IUnknown* pIUnknown;
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown));
if (FAILED(hr)) {
// the program goes here and return the hr
return hr;
}
hr = OleRun(pIUnknown);
if (SUCCEEDED(hr)) {
hr = pIUnknown->QueryInterface(GetIID(), reinterpret_cast<void**>(&m_pInterface));
}
pIUnknown->Release();
}
else {
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, GetIID(), reinterpret_cast<void**>(&m_pInterface));
}
return hr;
}
我不知道这里出了什么错误,这是头文件,我认为这里没有错误。有什么办法可以解决这个问题吗?
更新:
在我的RPTAInterface.tlh文件中,我看到了RPTAModuleInterface的声明。
struct /* coclass */ RPTAModuleInterface;
struct __declspec(uuid("d6134a6a-a08e-36ab-a4c0-c03c35aad201"))
RPTAModuleInterface;
RPTAModuleInterface
可能不是正确的值。它看起来更像是一个接口标识符而不是一个类标识符。CoCreateInstance()
需要一个类标识符而不是一个接口标识符。你明白它们之间的区别吗?你从哪里得到使用__uuidof(RPTAModuleInterface)
的想法呢? - Remy LebeauRPTAModuleInterface
是正确的 CoClass,则实现 CoClass 的 EXE/DLL 未在操作系统中注册。 您需要查找属于哪个应用程序并确保其已正确安装,我们无法在此处为您执行此操作。 另外,0x0022a360
不是失败的HRESULT
值,您确定这是CoCreateInstance()
返回的实际HRESULT
吗? “类未注册”错误消息通常与HRESULT
值0x80040154
相关联。 - Remy Lebeau