comportable-executablecom+tlbinf32

Get importlib directives from type library


How can one programmatically determine which type libraries (GUID and version) a given native, VB6-generated DLL/OCX depends on?

For background: The VB6 IDE chokes when opening a project where one of the referenced type libraries can't load one of its dependencies, but it's not so helpful as to say which dependency can't be met--or even which reference has the dependency that can't be met. This is a common occurrence out my company, so I'm trying to supplement the VB6 IDE's poor troubleshooting information.

Relevant details/attempts:

Really, if OLEView didn't do it I'd have given it up by now as impossible. Any thoughts on how to accomplish this?


Solution

  • It turns out that I was conflating basic DLL functionality and COM. (Not all DLLs are COM DLLs.)

    For basic DLLs, the Portable Executable format includes a section describing its imports. The Optional Header's directory 1 is about the DLL's imports. Its structure is given by IMAGE_IMPORT_DESCRIPTOR. This is a starting point for learning about that.

    COM DLLs don't seem to have an equivalent as such, but you can discover which other COM components its public interface needs: for each exposed interface, list out the types of their properties and their method arguments, and then use the Registry to look up where those types come from. tlbinf32.dll provides some of the basic functionality for listing members, etc. Here's and intro to that.