コード例 #1
0
        private static void ProcessFunctions(UnsafeNativeMethods.ITypeInfo typeInfo, IDictionary propInfoList, int dispidToGet, int nameDispID, ref bool addAboutBox, StructCache structCache)
        {
            IntPtr zero     = IntPtr.Zero;
            int    typeAttr = typeInfo.GetTypeAttr(ref zero);

            if (!System.Windows.Forms.NativeMethods.Succeeded(typeAttr) || (zero == IntPtr.Zero))
            {
                throw new ExternalException(System.Windows.Forms.SR.GetString("TYPEINFOPROCESSORGetTypeAttrFailed", new object[] { typeAttr }), typeAttr);
            }
            System.Windows.Forms.NativeMethods.tagTYPEATTR data = (System.Windows.Forms.NativeMethods.tagTYPEATTR)structCache.GetStruct(typeof(System.Windows.Forms.NativeMethods.tagTYPEATTR));
            UnsafeNativeMethods.PtrToStructure(zero, data);
            try
            {
                if (data != null)
                {
                    System.Windows.Forms.NativeMethods.tagFUNCDESC gfuncdesc = (System.Windows.Forms.NativeMethods.tagFUNCDESC)structCache.GetStruct(typeof(System.Windows.Forms.NativeMethods.tagFUNCDESC));
                    System.Windows.Forms.NativeMethods.tagELEMDESC structure = (System.Windows.Forms.NativeMethods.tagELEMDESC)structCache.GetStruct(typeof(System.Windows.Forms.NativeMethods.tagELEMDESC));
                    for (int i = 0; i < data.cFuncs; i++)
                    {
                        IntPtr pFuncDesc = IntPtr.Zero;
                        if (System.Windows.Forms.NativeMethods.Succeeded(typeInfo.GetFuncDesc(i, ref pFuncDesc)) && (pFuncDesc != IntPtr.Zero))
                        {
                            UnsafeNativeMethods.PtrToStructure(pFuncDesc, gfuncdesc);
                            try
                            {
                                if ((gfuncdesc.invkind == 1) || ((dispidToGet != -1) && (gfuncdesc.memid != dispidToGet)))
                                {
                                    if (gfuncdesc.memid == -552)
                                    {
                                        addAboutBox = true;
                                    }
                                }
                                else
                                {
                                    System.Windows.Forms.NativeMethods.tagTYPEDESC tdesc;
                                    bool flag = gfuncdesc.invkind == 2;
                                    if (flag)
                                    {
                                        if (gfuncdesc.cParams != 0)
                                        {
                                            continue;
                                        }
                                        tdesc = gfuncdesc.elemdescFunc.tdesc;
                                    }
                                    else
                                    {
                                        if ((gfuncdesc.lprgelemdescParam == IntPtr.Zero) || (gfuncdesc.cParams != 1))
                                        {
                                            continue;
                                        }
                                        Marshal.PtrToStructure(gfuncdesc.lprgelemdescParam, structure);
                                        tdesc = structure.tdesc;
                                    }
                                    PropInfo info = ProcessDataCore(typeInfo, propInfoList, gfuncdesc.memid, nameDispID, tdesc, gfuncdesc.wFuncFlags, structCache);
                                    if ((info != null) && !flag)
                                    {
                                        info.ReadOnly = 2;
                                    }
                                }
                            }
                            finally
                            {
                                typeInfo.ReleaseFuncDesc(pFuncDesc);
                            }
                        }
                    }
                    structCache.ReleaseStruct(gfuncdesc);
                    structCache.ReleaseStruct(structure);
                }
            }
            finally
            {
                typeInfo.ReleaseTypeAttr(zero);
                structCache.ReleaseStruct(data);
            }
        }