Click to See Complete Forum and Search --> : Accessing VB COM object from Vicual C++


KCP
April 12th, 2001, 06:52 AM
Hi, I wonder if anyone can help.

I have created a COM object in the form of a dll using VB6.

I would like to know how I can access this COM object in C++. I would usually use CoCreateInstance but that requires my C++ code to have knowledge of the interfaces supported by my VB COM object. I usually use the .H file containing the interfaces and IIDs (so I can declare a pointer to my interface, eg, KCPInterface* myInterfacePtr - then pass this to CoCreateInstance. I hope the above makes sense, thanks in advance for any help, I'm stuck on this one!!!

James Longstreet
April 12th, 2001, 08:22 AM
you can do one of two things.
a) use the class wizard and select Add New class. Then select from type library, and choose you dll. This is the harder way.

b) use smart pointers generated by using the #import directive.



#import "c:\my dlls\somedll.dll" no_namespace





this will generate the smartpointer and function definitions so that you can use them in your program. Take a look on MSDN for smart pointers or post something specific you want to do and I will try to help.



Jim Hewitt
Software Developer
Liberty Tax Service
www.LibertyTax.com