进程外COM服务器上的问题 [英] Questions on out-of-proc COM server

查看:120
本文介绍了进程外COM服务器上的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于使用ATL开发过程外(本地)COM服务器,我有几个问题.

我需要弄清楚如何使服务器作为单个实例运行.当前,客户端应用程序对CoCreateInstance的任何调用都会启动我的服务器的新实例.

我还有麻烦让QueryInterface在暴露的类上正常工作吗?我只能得到一个IUnknown ptr到我的对象.如果客户端调用QueryInterface以获得不同的接口,我可以通过跟踪(通过定义_ATL_DEBUG_INTERFACES和_ATL_DEBUG_QI)看到对我的对象(在exe中)的QI调用成功,但是refcount仅变为1,则QI成功,然后调用release,将refcount放回零.(我正在使用singleton类工厂.)客户端中的调用返回E_NOINTERFACE.

对于在何处获得帮助的任何想法或建议,我将不胜感激. .

谢谢.

Wayne

I have a couple of questions about developing an out-of-proc (local) COM server using ATL.

I need to figure out how to make the server function as a single instance. Currently, any call by a client app to CoCreateInstance will launch a new instance of my server. Is there a macro or define that I am missing?

I am also having trouble getting QueryInterface to work properly on an exposed class. I can only get a IUnknown ptr to my object. If the client calls QueryInterface to get a different interface, I can see via traces (from defining _ATL_DEBUG_INTERFACES and _ATL_DEBUG_QI) that the QI call on my object (in the exe) succeeds, but but the refcount is only going to 1, then QI succeeds, then release is called, dropping the refcount back to 0. (I am using the singleton class factory.) The call in the client is returning E_NOINTERFACE.

I would appreciate any ideas or suggestions on where to get help.

Thanks.

Wayne

推荐答案

要将服务器设为单个实例,您需要修改对RegisterClassObjects的调用到

hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,REGCLS_SINGLEUSE);
to get your server to be a single instance you need to modify the call to RegisterClassObjects to

hr = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE);


Ma-an,在开始之前就将其停在这里.这些天,没有人以正确的心态开始DCOM Server项目.自从Vista首次问世以来,它已经过时了几年.

您需要开发的是Windows服务;)
Ma-an, just stop it right there before you start. Nobody in his right mind starts on DCOM Server projects these days. It has been obsolete for a few years now, since Vista came out first.

What you need to develop is a Windows Service ;)


这篇关于进程外COM服务器上的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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