VC ++: Help Create a Simple COM Class

Can anyone help me create a simple COM class with VC ++ that I can call it a VB6 application using CreateObject?

Thanks!

+2


a source to share


1 answer


If you are using "raw C ++", there is an incredible amount of tedious detail you need to take care of, even for a simple base COM class. The easiest way to create a COM callable class in C ++ is ATL, which even comes with a wizard (at least in VS 2005 and 2008) for this purpose. The wizard will spit out a perfectly useful component including a reference count, registration, and one user interface. Keep in mind that VB uses late binding, so you need to implement IDispatch

in your class (you can use ATL IDispatchImpl

to make your life easier).



BTW, ATL gives you a very small footprint (it's a templating library) - just a VC ++ runtime, so there aren't many dependencies.

+2


a source







All Articles