• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 657
  • Last Modified:

[Type libraries] Getting the name of an Interface Identification...

I have a type library. The type library has a method that returns an IID of another COM class. I now need to know which class this IID belongs to.

Okay, first answer: use StringFromIID()... Well, wrong since this just returns me the GUID as a string.
Second answer: use ProgIDFromCLSID()... Wrong again since this method requires a CLSID, not an IID. The difference? CLSID's are registered in the registry...
Thirs answer: just maintain a list of possible GUID's in the type library and do a lookup of each GUID in an internal table. Okay, this works but it's not a good solution.

In other words, I need a better solution...

For those of you who use the ADO type library, one of the COM IID's that I try to convert to some readable text is IID__Recordset {00000555-0000-0010-8000-00AA006D2EA4} but the system will not provide me the proper name for this GUID. I know it is possible since Delphi can do this when it opens a type library. So what am I missing here???

I guess I'm missing the link to related type libraries. In other words, the dependency list of the type library... Guess I have to load the dependencies and then look into these type libraries to translate the IID correctly...
0
Wim ten Brink
Asked:
Wim ten Brink
  • 2
1 Solution
 
velterCommented:
You need to open the type lib and find the interface in it

Example to read the IID__Recordset Description

1 - Read the regsitry key HKCR\Interface\{00000555-0000-0010-8000-00AA006D2EA4}\TypeLib
This will give you the GUID of the typelib : {00000300-0000-0010-8000-00AA006D2EA4}

1 - Read the regsitry key HKCR\Interface\{00000555-0000-0010-8000-00AA006D2EA4}\TypeLib\Version
This will give you the version of the typelib : 2.5

2 - Read the registry key HKCR\TypeLib\{00000300-0000-0010-8000-00AA006D2EA4}\2.5\0\win32
This will give you the path of the type lib : C:\Program Files\Fichiers communs\System\ado\msador15.dll (for my system, might be different on yours)

3 - Load the typelib
LoadTypeLib('C:\Program Files\Fichiers communs\System\ado\msador15.dll',oTypeLib)

4 - Get the type info
oTypeLib.GetTypeInfoOfGuid(StringToGUID('{00000555-0000-0010-8000-00AA006D2EA4}',oTypeInfo)

4 - Get the name / doc string / help
oTypeInfo.GetDocumentation(MEMBERID_NIL,oName,oDocString,oHelpContext,oHelpFile);
0
 
Wim ten BrinkAuthor Commented:
Ewwwwwwww... I dislike that solution because I need to look into the registry. I am quite familiar with the registry, therefore I try to avoid using it as much as possible. It works but wonder if there's a non-registry solution too. So I keep this question open for a while and if someone provides a non-registry solution in the next two weeks, I'll double the points and split them between you and the other answer.
0
 
Wim ten BrinkAuthor Commented:
It seems to work okay and no one else could provide a better solution so, points to velter.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now