CoCreateInstance返回-2147221164?

GK_2014 2015-04-14 03:15:02
先贴代码吧:
 	
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 。是不是系统设置的问题?
...全文
612 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
I_ask_who 2015-04-17
  • 打赏
  • 举报
回复
引用 10 楼 GK_2014 的回复:
[quote=引用 7 楼 worldy 的回复:] 开始菜单-运行 输入 regsvr32 “DLL或ocx全路径名称” 注意路径名称加上引号,否则,路径有空格的时候会有问题
我把动态库放到了c:/WINDOWS/system32目录下,输入指令后提示已加载,但是找不到DLLRegisterServer入口点 [/quote] 源代码中(.c或者.cpp文件)没有定义DllRegisterServer,或者没有写相应的.def文件
GK_2014 2015-04-16
  • 打赏
  • 举报
回复
引用 9 楼 wyx100 的回复:
cmd 里面,先注册 对应的控件要到其他机器上先注册,regsvr32
我把动态库放到了c:/WINDOWS/system32目录下,输入指令后提示已加载,但是找不到DLLRegisterServer入口点
GK_2014 2015-04-16
  • 打赏
  • 举报
回复
引用 7 楼 worldy 的回复:
开始菜单-运行
输入 regsvr32 “DLL或ocx全路径名称”

注意路径名称加上引号,否则,路径有空格的时候会有问题


我把动态库放到了c:/WINDOWS/system32目录下,输入指令后提示已加载,但是找不到DLLRegisterServer入口点
wyx100 2015-04-15
  • 打赏
  • 举报
回复
cmd 里面,先注册 对应的控件要到其他机器上先注册,regsvr32
oyljerry 2015-04-15
  • 打赏
  • 举报
回复
引用 4 楼 GK_2014 的回复:
[quote=引用 1 楼 lx624909677 的回复:] http://blog.csdn.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)) { }
您好! 1、我查了下其他电脑上HKEY_CLASSES_ROOT的权限和我电脑上的一样; 2、为什么要注册msbn3.dll呢?我电脑没有注册也可以创建组建呀?[/quote] 你的电脑可能其他程序帮你注册了
worldy 2015-04-15
  • 打赏
  • 举报
回复
开始菜单-运行 输入 regsvr32 “DLL或ocx全路径名称” 注意路径名称加上引号,否则,路径有空格的时候会有问题
GK_2014 2015-04-15
  • 打赏
  • 举报
回复
引用 3 楼 worldy 的回复:
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.
不太懂怎么注册哦,求指导
GK_2014 2015-04-15
  • 打赏
  • 举报
回复
引用 2 楼 oyljerry 的回复:
对应的控件要到其他机器上先注册,regsvr32


您好!
我程序里是想调用封装了xml的动态库来创建xml文件,对应的clsid在我电脑的注册表可以找到,如下图:

但是其他电脑就没有注册XML DOM Document 4.0,我想问题就出在这里吧?怎么注册呢?求解答……
GK_2014 2015-04-15
  • 打赏
  • 举报
回复
引用 1 楼 lx624909677 的回复:
http://blog.csdn.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)) { }
您好! 1、我查了下其他电脑上HKEY_CLASSES_ROOT的权限和我电脑上的一样; 2、为什么要注册msbn3.dll呢?我电脑没有注册也可以创建组建呀?
worldy 2015-04-14
  • 打赏
  • 举报
回复
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.
oyljerry 2015-04-14
  • 打赏
  • 举报
回复
对应的控件要到其他机器上先注册,regsvr32
lx624909677 2015-04-14
  • 打赏
  • 举报
回复
http://blog.csdn.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)) { }

3,248

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧