CoCreateInstance回到-2147221164
CoCreateInstance返回-2147221164?
先贴代码吧:
在我电脑上可以创建组件,换了好几台其他电脑,函数CoCreateInstance返回-2147221164,注册表找不到m_ClsId 。是不是系统设置的问题?
------解决思路----------------------
http://blog.****.net/huigll/article/details/1459765
还有要给给msbn3.dll注册
参考下下面的代码:
CComPtr<IMMTGenerator> tGenerator;
const IID IID_IMMTGENERATOR = {0xC753602D,0x67AA,0x4B91,{0x97,0xD3,0x19,0xA7,0xE6,0x34,0x0D,0x70}};
CLSID clsid;
hr = CLSIDFromProgID( L"Generator.MMTGenerator" , &clsid );
if(FAILED(hr))
{
AfxMessageBox("Error: CLSIDFromProgID([Generator.MMTGenerator])");//
return;
}
hr = CoCreateInstance (clsid, 0, CLSCTX_INPROC_SERVER, IID_IMMTGENERATOR, (void**)&tGenerator);
if (SUCCEEDED(hr))
{
}
------解决思路----------------------
Your control is not registered correctly.
The "Logged On User" -- usually the anonymous account -- does not have adequate permissions to run the control. In many cases the anonymous login account (IUSR_<machine>) does not have appropriate permissions on certain Directories/Files or the specific component and its dependencies. While less frequent, if the registry permissions for certain keys are not set correctly, it causes the control to fail to initialize.
The "Everyone" group has been removed from having READ permissions on certain registry keys due to the mistaken notion that Everyone means ANYONE, when in actuality it simply means all validated users on the Domain/machine.
In the case of a file database, such as Access or FoxPro, the directory containing the database files does not provide sufficient permissions for the authenticated user.
------解决思路----------------------
开始菜单-运行
输入 regsvr32 “DLL或ocx全路径名称”
注意路径名称加上引号,否则,路径有空格的时候会有问题
------解决思路----------------------
源代码中(.c或者.cpp文件)没有定义DllRegisterServer,或者没有写相应的.def文件
先贴代码吧:
const CLSID CDOMDocument40Class::m_ClsId = {0x88d969c0, 0xf192, 0x11d4, {0xa6, 0x5f, 0x00, 0x40, 0x96, 0x32, 0x51, 0xe5}};
IXMLDOMDocument2 *p = NULL;
HRESULT hr = CoInitialize(NULL); //初始化COM
if (SUCCEEDED(hr)) {
hr = CoCreateInstance(m_ClsId, NULL, CLSCTX_ALL, __uuidof(IXMLDOMDocument2), (LPVOID*)&p);
if (hr != S_OK)
AfxThrowComException(hr);
}
else {
AfxThrowComException(hr);
}
在我电脑上可以创建组件,换了好几台其他电脑,函数CoCreateInstance返回-2147221164,注册表找不到m_ClsId 。是不是系统设置的问题?
------解决思路----------------------
http://blog.****.net/huigll/article/details/1459765
还有要给给msbn3.dll注册
参考下下面的代码:
CComPtr<IMMTGenerator> tGenerator;
const IID IID_IMMTGENERATOR = {0xC753602D,0x67AA,0x4B91,{0x97,0xD3,0x19,0xA7,0xE6,0x34,0x0D,0x70}};
CLSID clsid;
hr = CLSIDFromProgID( L"Generator.MMTGenerator" , &clsid );
if(FAILED(hr))
{
AfxMessageBox("Error: CLSIDFromProgID([Generator.MMTGenerator])");//
return;
}
hr = CoCreateInstance (clsid, 0, CLSCTX_INPROC_SERVER, IID_IMMTGENERATOR, (void**)&tGenerator);
if (SUCCEEDED(hr))
{
}
------解决思路----------------------
Your control is not registered correctly.
The "Logged On User" -- usually the anonymous account -- does not have adequate permissions to run the control. In many cases the anonymous login account (IUSR_<machine>) does not have appropriate permissions on certain Directories/Files or the specific component and its dependencies. While less frequent, if the registry permissions for certain keys are not set correctly, it causes the control to fail to initialize.
The "Everyone" group has been removed from having READ permissions on certain registry keys due to the mistaken notion that Everyone means ANYONE, when in actuality it simply means all validated users on the Domain/machine.
In the case of a file database, such as Access or FoxPro, the directory containing the database files does not provide sufficient permissions for the authenticated user.
------解决思路----------------------
开始菜单-运行
输入 regsvr32 “DLL或ocx全路径名称”
注意路径名称加上引号,否则,路径有空格的时候会有问题
------解决思路----------------------
源代码中(.c或者.cpp文件)没有定义DllRegisterServer,或者没有写相应的.def文件