Created
August 8, 2010 08:47
-
-
Save cstrahan/513775 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Here's an example of how to get info for a given COM type library. | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
using System.Text; | |
using TYPELIBATTR = System.Runtime.InteropServices.ComTypes.TYPELIBATTR; | |
namespace Sandbox | |
{ | |
class Program | |
{ | |
public class InnerSink : ITypeLibImporterNotifySink | |
{ | |
Assembly ITypeLibImporterNotifySink.ResolveRef(object typeLib) | |
{ | |
return null; | |
} | |
void ITypeLibImporterNotifySink.ReportEvent(ImporterEventKind eventKind, | |
int eventCode, | |
string eventMsg) | |
{ | |
} | |
} | |
public enum REGKIND | |
{ | |
REGKIND_DEFAULT = 0, | |
REGKIND_REGISTER, | |
REGKIND_NONE | |
} | |
[DllImport("oleaut32.dll", CharSet = CharSet.Unicode)] | |
public static extern void LoadTypeLibEx(string strTypeLibName, | |
REGKIND regKind, | |
out ITypeLib TypeLib); | |
static void Main(string[] args) | |
{ | |
ITypeLib typeLib; | |
LoadTypeLibEx("C:/Program Files (x86)/Apple Software Update/SoftwareUpdateAdmin.dll", | |
REGKIND.REGKIND_NONE, | |
out typeLib); | |
TYPELIBATTR tlibattr = new TYPELIBATTR(); | |
IntPtr ppTLibAttr; | |
typeLib.GetLibAttr(out ppTLibAttr); | |
tlibattr = (TYPELIBATTR)Marshal.PtrToStructure(ppTLibAttr, typeof(TYPELIBATTR)); | |
typeLib.ReleaseTLibAttr(ppTLibAttr); | |
Console.WriteLine(tlibattr.guid); | |
Console.WriteLine(tlibattr.lcid); | |
Console.WriteLine(tlibattr.syskind); | |
Console.WriteLine(tlibattr.wLibFlags); | |
Console.WriteLine(tlibattr.wMajorVerNum); | |
Console.WriteLine(tlibattr.wMinorVerNum); | |
Console.ReadKey(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment