tags:

views:

47

answers:

1

Hello guys!

Can someone guide me on how to create a simple COM class with VC++ that I can have it called by a VB6 app with CreateObject?

Thanks!

+2  A: 

If you use "raw C++" there's an unbelievable number of tedious details you need to take care of, even for just a basic COM class. By far the simplest way to create a COM-callable class in C++ is with ATL, which even comes with a wizard (at least in VS 2005 and 2008) for that purpose. The wizard will spit out a perfectly usable coclass including ref counting, registration, and one custom interface. Keep in mind that VB uses late binding, so you're gonna need to implement IDispatch on your class (you can use ATL's IDispatchImpl to simplify your life somewhat).

BTW, ATL gives you a very small footprint (it's a template library) - just the VC++ runtime, so not many dependencies.

Guido Domenici