How do I load a typelib to parse it in C#?
Asked Answered
C

1

7

In unmanaged code I can use LoadTypeLib() to obtain an ITypeLib* pointer and use that to look into the typelib to find what interfaces it contains.

There is System.Runtime.InteropServices.ComTypes.ITypeLib interface in C# but I can't find an equivalent to LoadTypeLib() function.

How do I load a typelib and obtain an ITypeLib reference in C#?

Chronopher answered 23/11, 2012 at 13:7 Comment(0)
Q
8

Copied straight from System.Design.NativeMethods, Reflector is useful:

[DllImport("oleaut32.dll", PreserveSig=false)]
public static extern ITypeLib LoadTypeLib([In, MarshalAs(UnmanagedType.LPWStr)] string typelib);
Qktp answered 23/11, 2012 at 13:16 Comment(1)
So the answer boils down to "PInvoke LoadTypeLib()" doesn't it?Chronopher

© 2022 - 2024 — McMap. All rights reserved.