public static List <KeyValuePair <string, string> > GetclsidsfromTLB(string filename) { List <KeyValuePair <string, string> > ret = new List <KeyValuePair <string, string> >(); try { TLI.TLIApplication tli = new TLI.TLIApplication(); TypeLibInfo ti = tli.TypeLibInfoFromFile(filename); foreach (CoClassInfo cc in ti.CoClasses) { Guid clsid = new Guid(cc.GUID); string progid = ""; ProgIDFromCLSID(ref clsid, out progid); if (progid == null) { progid = ti.Name + "." + cc.Name; } ret.Add(new KeyValuePair <string, string>(clsid.ToString("B"), progid)); } } catch { } return(ret); }
static void GatherDataFromTLB(Comobjectstorage comobj) { TLI.TLIApplication tli = new TLI.TLIApplication(); TypeLibInfo ti = tli.TypeLibInfoFromFile(comobj.path); foreach (CoClassInfo cc in ti.CoClasses) { string progid = comobj.progid; if (progid != "") { int k = progid.IndexOf('.'); if (k != -1) { comobj.namesp = progid.Substring(0, k); comobj.name = progid.Substring(k + 1).Replace('.', '_'); } } if (comobj.clsid.ToString("B").ToLower() != cc.GUID.ToLower()) { continue; } comobj.clsid = new Guid(cc.GUID); comobj.wcfclsid = Guid.NewGuid(); foreach (TLI.MemberInfo minf in cc.DefaultInterface.Members) { if (minf.AttributeMask != 0) { continue; } InvokeKinds functype = minf.InvokeKind; if (functype != TLI.InvokeKinds.INVOKE_FUNC && functype != TLI.InvokeKinds.INVOKE_PROPERTYGET && functype != TLI.InvokeKinds.INVOKE_PROPERTYPUT && functype != TLI.InvokeKinds.INVOKE_PROPERTYPUTREF) { continue; } if (functype != TLI.InvokeKinds.INVOKE_FUNC) { Comobjectstorage.classprops prop = comobj.findproperty(minf.Name); if (prop == null) { prop = new Comobjectstorage.classprops(); prop.name = minf.Name; prop.returntype = VarianttoManaged(minf.ReturnType); comobj.props.Add(prop); } if (functype == TLI.InvokeKinds.INVOKE_PROPERTYGET) { prop.bget = true; } else if (functype == TLI.InvokeKinds.INVOKE_PROPERTYPUT || functype == TLI.InvokeKinds.INVOKE_PROPERTYPUTREF) { prop.bset = true; } foreach (TLI.ParameterInfo pmi in minf.Parameters) { Comobjectstorage.paramtr par = new Comobjectstorage.paramtr(); par.name = pmi.Name; par.vartype = VarianttoManaged(pmi.VarTypeInfo); par.bref = false; if (pmi.VarTypeInfo.PointerLevel != 0) { par.bref = true; } (functype == TLI.InvokeKinds.INVOKE_PROPERTYGET ? prop.getpars : prop.setpars).Add(par); } } else { Comobjectstorage.classmtds mtd = new Comobjectstorage.classmtds(); mtd.name = minf.Name; mtd.returntype = VarianttoManaged(minf.ReturnType); foreach (TLI.ParameterInfo pmi in minf.Parameters) { if (pmi.Name == "OptionalArgs" && !bincoptional) { continue; } Comobjectstorage.paramtr par = new Comobjectstorage.paramtr(); par.name = pmi.Name; par.vartype = VarianttoManaged(pmi.VarTypeInfo); par.bref = false; if (pmi.VarTypeInfo.PointerLevel != 0) { par.bref = true; } mtd.pars.Add(par); } comobj.mtds.Add(mtd); } } } }