注册COM接口的实现 [英] Registering implementation of a COM interface

查看:879
本文介绍了注册COM接口的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是COM编程的新手。我有一个COM对象(和相关的IClassFactory)都准备好了,但我不能弄清楚如何注册结果DLL供其他程序使用。

I'm new to COM programming. I've got a COM object (and associated IClassFactory) all ready to go, but I can't quite figure out how to go about registering the resulting DLL for use by other programs. The number of GUIDs I need to sling around is also unclear to me.

我想要注册的COM对象实现了IAudioSessionEvents接口。

The COM object I'm trying to register implements the IAudioSessionEvents interface.

我遇到了DllRegisterServer和DllUnregisterServer函数,但我还没有找到任何明确的使用它们的演示。

I have come across the DllRegisterServer and DllUnregisterServer functions, but I haven't found any clear demonstrations of their usage. What keys do they deal with, how are they invoked, by what and when, etc.?

感谢,

-Kevin Montrose

Thanks,
-Kevin Montrose

推荐答案

我不确定从这个帖子,无论是实现还是使用支持IAudioSessionEvents的DLL。如果你使用这个DLL,那么你可以使用注释行实用程序regsvr32注册组件。要注册使用:

I'm not sure from this post whether you are implementing or consuming the DLL that supports IAudioSessionEvents. If you're consuming this DLL, then you can register the component using the comment line utility regsvr32. To register use:

regsvr32

要取消注册:

regsvr32 / u

regsvr32 /u

regsvr32应在您的路径上,因此此命令将在任何目录下工作。

regsvr32 should be on your path, so this command will work from any directory.

如果您正在实现相关的DLL,那么您必须提供DllRegisterServer和DllUnRegisterServer函数的实现。这些函数必须设置和清除组件的注册表项。注册表项的目的是提供ProgID,将其映射到CLSID,并为组件支持的接口提供接口ID。例如,IAudioSessionEvent的接口ID。如果你正在实现DLL,你必须提供代码来执行所有这些任务。

If you are implementing the DLL in question, then you must provide an implementaion of the DllRegisterServer and DllUnRegisterServer functions. These functions must set up and clean up registry entries for your component. The purpose of the registry entries is to provide a ProgID, map it to a CLSID, and provid interface ID for the interfaces that the component supports. For example, the interface ID for IAudioSessionEvent. If you're implementing the DLL, you'll have to provide code to perform all of these tasks.

注意:这些函数被regsvr32调用,以便注册组件。

Note: these functions are called by regsvr32 in order to register the component.

如果真的写这个代码非常不寻常,通常你会想要使用一个框架像ATL,它照顾你的繁忙工作。如果你真的想从头开始知道COM,这是一个很好的练习,至少写一次这个代码。

If very unusual to actually write this code, generally you'll want to use a framework like ATL, which takes care of the busywork for you. It is a good exercise to write this code at least once if you really want to know COM from the ground up.

这篇关于注册COM接口的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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