private bool IsCreatableCoClass(TYPEATTR typeAttr) {
     return typeAttr.typekind == TYPEKIND.TKIND_COCLASS
         && typeAttr.wTypeFlags == TYPEFLAGS.TYPEFLAG_FCANCREATE;
 }
Example #2
0
File: Form1.cs Project: rojac07/COM
        private void FillListBoxes(UCOMITypeLib itfTypeLib)
        {
            // Clear out current contents.
            lstBoxCoclasses.Items.Clear();
            lstBoxInterfaces.Items.Clear();
            lstBoxEnums.Items.Clear();

            // Get # of COM types in the library.
            int typeCount = itfTypeLib.GetTypeInfoCount();
            lblNumbOfTypes.Text = "Number of COM Types in file: " + typeCount.ToString();

            // Switch between COM type.
            // Dump out the types.
            for(int typeIndex = 0; typeIndex < typeCount; typeIndex++)
            {
                string typeInfoString;
                UCOMITypeInfo pInfo;

                // Get TYPEATTR structure set up.
                TYPEATTR typeAtt = new TYPEATTR();
                Type TYPEATTRType = typeAtt.GetType();
                int structSize = Marshal.SizeOf(TYPEATTRType);
                IntPtr ptr = IntPtr.Zero;
                ptr = Marshal.AllocHGlobal(structSize);

                // Get next type info.
                itfTypeLib.GetTypeInfo(typeIndex, out pInfo);
                pInfo.GetTypeAttr(out ptr);
                typeAtt = (TYPEATTR) Marshal.PtrToStructure(ptr, TYPEATTRType);

                // Based on the kind of COM type, print out some information.
                string typeName, helpFile, docString;
                int helpID;

                switch(typeAtt.typekind)
                {
                    case TYPEKIND.TKIND_COCLASS:  // type is a coclass.
                        pInfo.GetDocumentation(-1, out typeName, out docString,
                                               out helpID, out helpFile);
                        typeInfoString = "Name: " + typeName + "\tCLSID: {" + typeAtt.guid.ToString() + "}";
                        lstBoxCoclasses.Items.Add(typeInfoString);
                    break;

                    case TYPEKIND.TKIND_INTERFACE:  // type is a interface.
                    case TYPEKIND.TKIND_DISPATCH:
                        pInfo.GetDocumentation(-1, out typeName, out docString,
                            out helpID, out helpFile);
                        typeInfoString = "Name: " + typeName + "\tIID: {" + typeAtt.guid.ToString() + "}";
                        lstBoxInterfaces.Items.Add(typeInfoString);
                    break;

                    case TYPEKIND.TKIND_ENUM:  // type is a enum.
                        pInfo.GetDocumentation(-1, out typeName, out docString,
                            out helpID, out helpFile);
                        typeInfoString = "Name: " + typeName;
                        lstBoxEnums.Items.Add(typeInfoString);
                    break;
                }
                Marshal.DestroyStructure(ptr, typeAtt.GetType());
            }
        }
 private bool IsIDispatchInterface(TYPEATTR typeAttr) {
     return typeAttr.typekind == TYPEKIND.TKIND_DISPATCH;
 }