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!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
IDispatchon your class (you can use ATL’sIDispatchImplto 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.