Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Registering implementation of a COM interface

Tags:

c++

windows

com

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.

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

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.?

Thanks,
-Kevin Montrose

like image 619
Kevin Montrose Avatar asked Aug 01 '26 04:08

Kevin Montrose


1 Answers

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

To unregister:

regsvr32 /u

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

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.

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

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.

like image 55
Paul Keister Avatar answered Aug 02 '26 18:08

Paul Keister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!