如何为一个COM对象添加多个接口 [英] How to add morethan one interface for a COM object

查看:116
本文介绍了如何为一个COM对象添加多个接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个COM DLL服务器项目,并通过创建具有CoCreateInstance()的客户端访问了它.

然后,我通过添加另一个接口来修改COM服务器项目.

为了获得第二个接口的对象,我调用了QueryInterface函数.

但是QueryInterface始终返回"E_NOINTERFACE".

我正在犯什么错误,请澄清.

创建第二个界面时,我们需要牢记哪些要点?

敬请指教.

谢谢,
Ganesamoorthy

Hi,

I have created a COM DLL Server Project and accessed it by creating a clinet having CoCreateInstance().

Then i have modified the COM server project by adding one more interface.

In order to obtain the object for the second interface, i have called the QueryInterface function.

But QueryInterface always returns "E_NOINTERFACE".

What is the mistake i am making, please clarify.

What are the points we need to keep in mind while creating the second interface?

Kindly Advise.

Thanks,
Ganesamoorthy

推荐答案

我自己完成了此操作.

将接口添加到COM就像往常一样,但是如果我们假设使用QUERYINTERFACE,则必须实现它.

我做到了,并得到了预期的结果.
I have completed this on my own.

Adding interface to a COM, is as usual but if we suppose to use QUERYINTERFACE then it has to be implemented.

I did it and got the expected result.


您是否更新了.idl文件?
如果没有,请对其进行更新.

使用midl工具来编译您的.idl文件.
在项目中添加更改的文件(存根和客户端).

然后使用您的COM对象.
希望这对您有所帮助. ; P
Have you updated the .idl file?
If not then update it.

Use the midl tool to compile your .idl file.
Add the changed files (stub and client) in your project.

Then use your COM object.
Hope this have helped you. ;P


这篇关于如何为一个COM对象添加多个接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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