Talk:Migrating C++ Code from import to TLIBIMP.EXE
This great. The key item missing, however, is that "TLIBIMP declares the coclass as a simple typedef of the default interface of the coclass". IOW
With #import, __uuidof(CoClass) returns the GUID of the CoClass With TLIBIMP, __uuidof(CoClass) returns the GUID of the default interface of the CoClass.
Thanks!
Bruneau
Please replace the ridl code (first code) with the following:
[
uuid(ECD2547D-5BC5-49C6-A7D1-9D55C0A9F0DF),
version(1.0)
]
library TestLibrary
{
importlib("stdole2.tlb");
coclass CoClass1;
interface Interface1;
[
uuid(AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA),
dual,
oleautomation
]
interface Interface1: IDispatch
{
};
[
uuid(CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC),
]
coclass CoClass1
{
[default] interface Interface1;
};
};
The code that's there is the original that I wrote. But then I changed the GUIDs to AAAAA an CCCCC to make it easier to see which was the CoClass' and which was the interface's. However, I forgot to update the .ridl code after that change. Thank you BBabet
I would not necessarily say
The #import directive incorrectly associates the GUID of a coclass with the C++ type representing the coclass. TLIBIMP correctly associates the class identifer (CLSID) as the GUID of the coclass.
The issue is the usage of correctly and incorrectly. Matter of fact, #import is the one which correctly associates the correct GUID. TLIBIMP does something different to follow what Delphi does/did. So I would probably leave out the 'correctly' and 'incorrectly'.
Response
I have incorporated your comments and used your text for the bullets at the beginning. Many thanks!
KrisHouser 13:32, 7 July 2011 (PDT)