CreateInstance()失败,C ++ COM中的错误代码为1008 [英] CreateInstance() fails with error code 1008 in C++ COM

查看:643
本文介绍了CreateInstance()失败,C ++ COM中的错误代码为1008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2010 ULTIMATE - 创建服务器和客户端。

操作系统:VISTA



模块名称:服务器

组件名称:数学



我正在尝试以下方法来使用com组件。

Visual Studio 2010 ULTIMATE - To create both server and client.
OS: VISTA

Module name : Server
Component Name: Maths

I'm trying the following to use the com component.

CoInitialize(NULL);

IMathsPtr ptr;
HRESULT hr = ptr.CreateInstance("Server.Maths"); // To create  the co object.
// here I am getting Invalid class string - during debugging







我在注册表中注册了COM组件。在构建Server应用程序时,它会自动注册。

也尝试用regsvr32注册。

但是这里我的问题是如何从注册表或任何其他方式获取有效的类字符串。

在Visual Studio 2010终极版中,我找不到OLE对象查看器的任何选项!!!



任何有任何意义的机构这个,请分享。



FYI:我在注册表中搜索了这个,找不到。



谢谢,

Subrat。




I have registered the COM component in the registry. During building Server app, it automatically registers.
Also tried with regsvr32 to register.
But here my Question is how to get the valid class string fro registry or any other way.
In Visual studio 2010 ultimate, I am not finding any option for OLE Object viewer!!!

Any body having any point on this, please share.

FYI: I searched this in registry, couldn't find.

Thanks,
Subrat.

推荐答案

事实是:COM错误是错误。 (听起来胡说八道,但它的真实性)



如果你在注册表中找不到字符串而不是注册!!! :-O

修复它! =>以admin身份运行寄存器并检查错误代码。它必须是NULL。



你最好写:

The truths is: COM error are errors. (sounds nonsense but its true)

If you cant find the string in the registry than it isnt registered!!! :-O
Fix it! => Run the register as admin and check the error code. It must be NULL.

You better write:
HRESULT hr = ptr.CreateInstance(TEXT("Server.Maths")); // To create  the co object.





考虑学习这篇精美的文章 COM in plain C 更好地理解它。这是一篇优秀的文章!!!



Consider studying this fine article COM in plain C to better understand it. It is an outstanding article!!!


SOln很简单。我在VC 6.0中使用了COM。其中progID将由向导通过说明modulename.component名称进行创建。但在VS2010中,情况并非如此。在创建Component期间,我们需要手动提供progID。这解决了这个问题。
SOln is simple. I used COM in VC 6.0. Where progID would be created atoatically by the wizard, by saying modulename.component name. But in VS2010, it's not the case. During creation of Component, we need to manually provide the progID. This solves the problem.


如果没有以管理员身份运行注册,它将永远不会运行:(

我已经完成了。我在管理模式下运行VS创建COM服务器。否则它会抛出错误:)



你能告诉e究竟在哪里搜索字符串吗? / ROOT / CLSID ????或其他任何事情。我已经完成了整个搜索。
Without runing register as admin, it'll never run:(
Already I have done that. I ran VS in admin mode while creating COM server. Else it'll throw error:)

Can you tell e where exactly to search the string? /ROOT/CLSID???? or anything else.i already did a entire search.


这篇关于CreateInstance()失败,C ++ COM中的错误代码为1008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆