Search code examples
visual-c++comvb6

Which type library hosts stdDataFormat?


I am trying to import VB6's VBRUN type library into a Visual C++ 2017 header file, but it is failing due to a missing dependency.

Visual C++ reports

"error C4772: #import referenced a type from a missing type library; 'missing_type' used as a placeholder"

Viewing the file with OLE View reveals the problem is with the DataFormat property (DataFormat([out, retval] --<GetRefTypeInfo failed>** Return)).

The missing dependency would appear to be stdDataFormat: which type library does stdDataFormat reside in and why is it missing? (My operating system is Windows 10 Enterprise, 21H1.) Did I miss a selection when installing Visual Studio 6?


Solution

  • This addresses the first part of the question, how to find the typelib (TLB) containing a given interface or class.


    Assuming you have no preconception about the TLB / DLL hosting a given COM interface or class you can find it by a couple of registry searches, assuming the type in question actually has been registered.

    I started off in HKEY_CLASSES_ROOT with a search for data values = stdDataFormat. This lead to:

    [HKEY_CLASSES_ROOT\MSSTDFMT.StdDataFormat]
    @="StdDataFormat Object"
    
    [HKEY_CLASSES_ROOT\MSSTDFMT.StdDataFormat\CLSID]
    @="{6D835690-900B-11D0-9484-00A0C91110ED}"
    

    Now armed with the CLSID GUID of 6D835690-900B-11D0-9484-00A0C91110ED, search for that value, finding:

    HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{6D835690-900B-11D0-9484-00A0C91110ED
    

    of which its important sub-element for our purposes is:

    [HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{6D835690-900B-11D0-9484-00A0C91110ED}\InprocServer32]
    @="c:\\windows\\SysWow64\\msstdfmt.dll"
    ...
    

    The InprocServer32 value was the main thing I wanted to find; it tells you the DLL - which is c:\windows\SysWow64\msstdfmt.dll (on my PC - but this should be typical).

    Opening msstdfmt.dll in OLEView (or OLEViewDotNet) confirms this; the decompiled IDL from the TLB in that DLL contains:

    [
      uuid(6D835690-900B-11D0-9484-00A0C91110ED),
      helpstring("StdDataFormat Object"),
      helpcontext(0x00066b5f)
    ]
    coclass StdDataFormat {
        [default] interface IStdDataFormatDisp;
        [default, source] dispinterface IStdDataFormatEvents;
    };
    

    So msstdfmt.dll should be the missing dependency.

    If you did suspect this DLL to begin with, then obviously its a lot quicker to just load it in OLEView and check. But in many cases that won't be obvious when you're starting out.


    As for the second part of the question - why is this dependency missing - maybe it would help if you added the relevant section of your code / includes?