How to extract a GUID from a Win32 DLL or OCX

后端 未结 2 906
说谎
说谎 2021-01-14 05:59

We have a .NET app that needs to examine a folder that may contain COM libraries (DLL and OCX.) When we do encounter a COM library one thing we need to accomplish is to extr

相关标签:
2条回答
  • 2021-01-14 06:12

    You will have to use interop (both P/Invoke and COM) in order to do this. First, you will have to call the LoadTypeLib to get the ITypeLib interface for the type library.

    From there, you will have to use the methods on that in order to get the GUID for the library, or get the CLSID or IID instances for anything defined in the library.

    0 讨论(0)
  • 2021-01-14 06:19

    This should work for you. It requires a reference to c:\windows\system32\tlbinf32.dll, but I'm assuming that is okay because it isn't a third party component.

    Imports TLI 'from c:\windows\system32\tlbinf32.dll
    
    Dim reglib As TLI.TLIApplication = New TLI.TLIApplicationClass()
    Dim DLLPath As String = "c:\mycomponent.ocx"
    MsgBox(reglib.TypeLibInfoFromFile(DLLPath).GUID.ToString())
    
    0 讨论(0)
提交回复
热议问题