如何将应用程序作为COM服务器或独立应用程序执行 [英] How to the Application is executing as COM srever or Standalone app

查看:76
本文介绍了如何将应用程序作为COM服务器或独立应用程序执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个可以作为独立服务器或com服务器执行的应用程序.现在,在应用程序内部有没有办法知道当前实例是否作为独立应用程序或COM服务器运行.

如果应用程序/服务器是使用CWinApp编写的,则可以调用ParseCommandLine方法,如果m_bRunAutomated是服务器


IUnknown的内部QueryInterface怎么样?如果它的计数为2,则说明它是COM服务器-但要确保它已释放.如果遇到未初始化COM之类的错误,则不是这样.


Hi,
I have an application which can be executed as a standalone or a com server.Now, is there any way, inside application to know wether the current instance is running as standalone application or COM server.

解决方案

if the app/server is written using CWinApp, you could call the ParseCommandLine method, and m_bRunAutomated will be set if it''s a server


How about Internal QueryInterface for IUnknown? If it works with a count of, say, 2 then its a COM server - but make sure its released. If you get an error like COM not initialised, it''s not.


这篇关于如何将应用程序作为COM服务器或独立应用程序执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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