germaks
asked on
How to use ATL COM object created in VC++ in another ATL COM object in VC++
I have ATL COM created in MS Visual C++ 6.0, now I would like to use that in the different ATL COM object. How do I do it? Are there any changes to existing ATL Object in order to make it usable in a new ATL object? What do I have to do to get functionality of first ATL object in the second ATL object. I have a source code for first object and .dll and .lib files.
More details please.
More details please.
ASKER
It almost works,
when I compile it I get the error that CreateObject is not a member of '_com_ptr_t<class _com_IIID<struct IVerify,&struct __s_GUID _GUID_bc555c18_f885_4b65_a ebf_683ba8 1cc964> >'
here is the code
IVerifyPtr LicV;
LicV.CreateObject( __uuidof(Verify) );
when I compile it I get the error that CreateObject is not a member of '_com_ptr_t<class _com_IIID<struct IVerify,&struct __s_GUID _GUID_bc555c18_f885_4b65_a
here is the code
IVerifyPtr LicV;
LicV.CreateObject( __uuidof(Verify) );
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> I have ATL COM created in MS Visual C++ 6.0, now I would like to use that in
> the different ATL COM object. How do I do it? Are there any changes to existing
> ATL Object in order to make it usable in a new ATL object? What do I have to
> do to get functionality of first ATL object in the second ATL object. I have
> a source code for first object and .dll and .lib files.
I would do it like this. In a header file for your new ATL object, add this:
#import "<PATH>\ObjectOne.dll" no_namespaces
(Where <PATH> and ObjectOne point to your original DLL file).
Then, here is some sample code of using your object (called YourObject, in this example). Be sure to wrap your code in try/catch blocks to catch _com_error& e's.
try
{
IYourObjectPtr spObject;
spObject.CreateObject( __uuidof(YourObject) );
spObject->SomeMethod();
}
catch ( _com_error& e )
{
// Handle the error
}
Hope that helps,
Dex*