当前位置: 首页>>代码示例>>C#>>正文


C# InteropServices.ComTypes类代码示例

本文整理汇总了C#中System.Runtime.InteropServices.ComTypes的典型用法代码示例。如果您正苦于以下问题:C# ComTypes类的具体用法?C# ComTypes怎么用?C# ComTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComTypes类属于System.Runtime.InteropServices命名空间,在下文中一共展示了ComTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComTypeEnumDesc

        internal ComTypeEnumDesc(ComTypes.ITypeInfo typeInfo, ComTypeLibDesc typeLibDesc) :
            base(typeInfo, ComType.Enum, typeLibDesc) {
            ComTypes.TYPEATTR typeAttr = ComRuntimeHelpers.GetTypeAttrForTypeInfo(typeInfo);
            string[] memberNames = new string[typeAttr.cVars];
            object[] memberValues = new object[typeAttr.cVars];

            IntPtr p = IntPtr.Zero;

            // For each enum member get name and value.
            for (int i = 0; i < typeAttr.cVars; i++) {
                typeInfo.GetVarDesc(i, out p);

                // Get the enum member value (as object).
                ComTypes.VARDESC varDesc;

                try {
                    varDesc = (ComTypes.VARDESC)Marshal.PtrToStructure(p, typeof(ComTypes.VARDESC));

                    if (varDesc.varkind == ComTypes.VARKIND.VAR_CONST) {
                        memberValues[i] = Marshal.GetObjectForNativeVariant(varDesc.desc.lpvarValue);
                    }
                } finally {
                    typeInfo.ReleaseVarDesc(p);
                }

                // Get the enum member name
                memberNames[i] = ComRuntimeHelpers.GetNameOfMethod(typeInfo, varDesc.memid);
            }

            _memberNames = memberNames;
            _memberValues = memberValues;
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:32,代码来源:ComTypeEnumDesc.cs

示例2: GetNameOfType

        internal static string GetNameOfType(ComTypes.ITypeInfo typeInfo) {
            string name;
            string documentation;
            GetInfoFromType(typeInfo, out name, out documentation);

            return name;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:ComRuntimeHelpers.cs

示例3: GetNameOfLib

        internal static string GetNameOfLib(ComTypes.ITypeLib typeLib) {
            string name;
            string strDocString;
            int dwHelpContext;
            string strHelpFile;

            typeLib.GetDocumentation(-1, out name, out strDocString, out dwHelpContext, out strHelpFile);
            return name;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:9,代码来源:ComRuntimeHelpers.cs

示例4: GetFromTypeLib

        internal static ComTypeLibDesc GetFromTypeLib(ComTypes.ITypeLib typeLib) {
            // check whether we have already loaded this type library
            ComTypes.TYPELIBATTR typeLibAttr = ComRuntimeHelpers.GetTypeAttrForTypeLib(typeLib);
            ComTypeLibDesc typeLibDesc;
            lock (_CachedTypeLibDesc) {
                if (_CachedTypeLibDesc.TryGetValue(typeLibAttr.guid, out typeLibDesc)) {
                    return typeLibDesc;
                }
            }

            typeLibDesc = new ComTypeLibDesc();

            typeLibDesc._typeLibName = ComRuntimeHelpers.GetNameOfLib(typeLib);

            int countTypes = typeLib.GetTypeInfoCount();
            for (int i = 0; i < countTypes; i++) {
                ComTypes.TYPEKIND typeKind;
                typeLib.GetTypeInfoType(i, out typeKind);

                ComTypes.ITypeInfo typeInfo;
                if (typeKind == ComTypes.TYPEKIND.TKIND_COCLASS) {
                    typeLib.GetTypeInfo(i, out typeInfo);
                    ComTypeClassDesc classDesc = new ComTypeClassDesc(typeInfo);
                    typeLibDesc._classes.AddLast(classDesc);
                } else if (typeKind == ComTypes.TYPEKIND.TKIND_ENUM) {
                    typeLib.GetTypeInfo(i, out typeInfo);
                    ComTypeEnumDesc enumDesc = new ComTypeEnumDesc(typeInfo);
                    typeLibDesc._enums.Add(enumDesc.TypeName, enumDesc);
                }
            }

            // cache the typelib using the guid as the dictionary key
            lock (_CachedTypeLibDesc) {
                //check if we are late and somebody already added the key.
                ComTypeLibDesc curLibDesc;
                if (_CachedTypeLibDesc.TryGetValue(typeLibAttr.guid, out curLibDesc)) {
                    return curLibDesc;
                }

                _CachedTypeLibDesc.Add(typeLibAttr.guid, typeLibDesc);
            }

            return typeLibDesc;
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:44,代码来源:ComTypeLibDesc.cs

示例5: SetFileTimeProxy

        public int SetFileTimeProxy(
            IntPtr rawFileName,
            ref ComTypes.FILETIME rawCreationTime,
            ref ComTypes.FILETIME rawLastAccessTime,
            ref ComTypes.FILETIME rawLastWriteTime,
            ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string file = GetFileName(rawFileName);

                long time;

                time = ((long)rawCreationTime.dwHighDateTime << 32) + (uint)rawCreationTime.dwLowDateTime;
                DateTime ctime = DateTime.FromFileTime(time);
                
                if (time == 0)
                    ctime = DateTime.MinValue;

                time = ((long)rawLastAccessTime.dwHighDateTime << 32) + (uint)rawLastAccessTime.dwLowDateTime;
                DateTime atime = DateTime.FromFileTime(time);

                if (time == 0)
                    atime = DateTime.MinValue;

                time = ((long)rawLastWriteTime.dwHighDateTime << 32) + (uint)rawLastWriteTime.dwLowDateTime;
                DateTime mtime = DateTime.FromFileTime(time);

                if (time == 0)
                    mtime = DateTime.MinValue;

                return operations_.SetFileTime(
                    file, ctime, atime, mtime, GetFileInfo(ref rawFileInfo));

            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return -1;
            }
        }
开发者ID:cristhiand3,项目名称:mssqlfs,代码行数:41,代码来源:Proxy.cs

示例6: GetInfoFromType

        internal static void GetInfoFromType(ComTypes.ITypeInfo typeInfo, out string name, out string documentation) {
            int dwHelpContext;
            string strHelpFile;

            typeInfo.GetDocumentation(-1, out name, out documentation, out dwHelpContext, out strHelpFile);
        }
开发者ID:andreakn,项目名称:ironruby,代码行数:6,代码来源:ComRuntimeHelpers.cs

示例7: GetTypeAttrForTypeLib

        internal static ComTypes.TYPELIBATTR GetTypeAttrForTypeLib(ComTypes.ITypeLib typeLib) {
            IntPtr pAttrs = IntPtr.Zero;
            typeLib.GetLibAttr(out pAttrs);

            // GetTypeAttr should never return null, this is just to be safe
            if (pAttrs == IntPtr.Zero) {
                throw Error.CannotRetrieveTypeInformation();
            }

            try {
                return (ComTypes.TYPELIBATTR)Marshal.PtrToStructure(pAttrs, typeof(ComTypes.TYPELIBATTR));
            } finally {
                typeLib.ReleaseTLibAttr(pAttrs);
            }
        }
开发者ID:andreakn,项目名称:ironruby,代码行数:15,代码来源:ComRuntimeHelpers.cs

示例8: ComMethodInformation

 internal ComMethodInformation(bool hasvarargs, bool hasoptional, ParameterInformation[] arguments, Type returnType, int dispId, COM.INVOKEKIND invokekind)
     : base(hasvarargs, hasoptional, arguments)
 {
     this.ReturnType = returnType;
     this.DispId = dispId;
     this.InvokeKind = invokekind;
 }
开发者ID:40a,项目名称:PowerShell,代码行数:7,代码来源:ComMethod.cs

示例9: ComTypeInfo

        /// <summary>
        ///  Constructor
        /// </summary>
        /// <param name="info">ITypeInfo object being wrapped by this object</param>
        internal ComTypeInfo(COM.ITypeInfo info)
        {
            _typeinfo = info;
            _properties = new Dictionary<String, ComProperty>(StringComparer.OrdinalIgnoreCase);
            _methods = new Dictionary<String, ComMethod>(StringComparer.OrdinalIgnoreCase);

            if (_typeinfo != null)
            {
                Initialize();
            }
        }
开发者ID:40a,项目名称:PowerShell,代码行数:15,代码来源:ComTypeInfo.cs

示例10: FiletimeToDateTime

        private DateTime FiletimeToDateTime(ComType.FILETIME FileTime)
        {
            try
            {
                if (FileTime.dwLowDateTime < 0) FileTime.dwLowDateTime = 0;
                if (FileTime.dwHighDateTime < 0) FileTime.dwHighDateTime = 0;

                long RawFileTime = (((long)FileTime.dwHighDateTime) << 32) + FileTime.dwLowDateTime;
                return DateTime.FromFileTimeUtc(RawFileTime);
            }
            catch { return new DateTime(); }
        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:12,代码来源:DateTypes.cs

示例11: Stat

 public void Stat(out COMTypes.STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new COMTypes.STATSTG();
     pstatstg.cbSize = this.stm.Length;
 }
开发者ID:redshiftrobotics,项目名称:telemetry_Archive,代码行数:5,代码来源:WIN32.cs

示例12: Clone

 //----------------------------------
 // IStream
 //----------------------------------
 public void Clone(out COMTypes.IStream ppstm)
 {
     throw new NotImplementedException();
 }
开发者ID:redshiftrobotics,项目名称:telemetry_Archive,代码行数:7,代码来源:WIN32.cs

示例13: GetTypeFromTypeDesc

 /// <summary>
 ///  Determine .net type for the given type descriptor
 /// </summary>
 /// <param name="typedesc">COM type descriptor to convert</param>
 /// <returns>type represented by the typedesc</returns>
 internal static Type GetTypeFromTypeDesc(COM.TYPEDESC typedesc)
 {
     VarEnum vt = (VarEnum)typedesc.vt;
     return VarEnumSelector.GetTypeForVarEnum(vt);
 }
开发者ID:40a,项目名称:PowerShell,代码行数:10,代码来源:ComUtil.cs

示例14: GetStringFromTypeDesc

        // Disable obsolete warning about VarEnum in CoreCLR
#pragma warning disable 618

        /// <summary>
        /// This function gets a string representation of the Type Descriptor
        /// This is used in generating signature for Properties and Methods.
        /// </summary>
        /// <param name="typeinfo">Reference to the type info to which the type descriptor belongs</param>
        /// <param name="typedesc">reference to type descriptor which is being converted to string from</param>
        /// <returns>string representation of the type descriptor</returns>
        private static string GetStringFromTypeDesc(COM.ITypeInfo typeinfo, COM.TYPEDESC typedesc)
        {
            if ((VarEnum)typedesc.vt == VarEnum.VT_PTR)
            {
                COM.TYPEDESC refdesc = ClrFacade.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
                return GetStringFromTypeDesc(typeinfo, refdesc);
            }

            if ((VarEnum)typedesc.vt == VarEnum.VT_SAFEARRAY)
            {
                COM.TYPEDESC refdesc = ClrFacade.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
                return "SAFEARRAY(" + GetStringFromTypeDesc(typeinfo, refdesc) + ")";
            }

            if ((VarEnum)typedesc.vt == VarEnum.VT_USERDEFINED)
            {
                return GetStringFromCustomType(typeinfo, typedesc.lpValue);
            }

            switch ((VarEnum)typedesc.vt)
            {
                case VarEnum.VT_I1:
                    return "char";

                case VarEnum.VT_I2:
                    return "short";

                case VarEnum.VT_I4:
                case VarEnum.VT_INT:
                case VarEnum.VT_HRESULT:
                    return "int";

                case VarEnum.VT_I8:
                    return "int64";

                case VarEnum.VT_R4:
                    return "float";

                case VarEnum.VT_R8:
                    return "double";

                case VarEnum.VT_UI1:
                    return "byte";

                case VarEnum.VT_UI2:
                    return "ushort";

                case VarEnum.VT_UI4:
                case VarEnum.VT_UINT:
                    return "uint";

                case VarEnum.VT_UI8:
                    return "uint64";

                case VarEnum.VT_BSTR:
                case VarEnum.VT_LPSTR:
                case VarEnum.VT_LPWSTR:
                    return "string";

                case VarEnum.VT_DATE:
                    return "Date";

                case VarEnum.VT_BOOL:
                    return "bool";

                case VarEnum.VT_CY:
                    return "currency";

                case VarEnum.VT_DECIMAL:
                    return "decimal";

                case VarEnum.VT_CLSID:
                    return "clsid";

                case VarEnum.VT_DISPATCH:
                    return "IDispatch";

                case VarEnum.VT_UNKNOWN:
                    return "IUnknown";

                case VarEnum.VT_VARIANT:
                    return "Variant";

                case VarEnum.VT_VOID:
                    return "void";

                case VarEnum.VT_ARRAY:
                    return "object[]";

                case VarEnum.VT_EMPTY:
//.........这里部分代码省略.........
开发者ID:40a,项目名称:PowerShell,代码行数:101,代码来源:ComUtil.cs

示例15: GetStringFromCustomType

        /// <summary>
        ///  Gets the name of the custom type defined in the type library
        /// </summary>
        /// <param name="typeinfo">ITypeInfo interface of the type</param>
        /// <param name="refptr">reference to the custom type</param>
        /// <returns>name of the custom type</returns>
        private static string GetStringFromCustomType(COM.ITypeInfo typeinfo, IntPtr refptr)
        {
            COM.ITypeInfo custtypeinfo;
            int reftype = unchecked((int)(long)refptr); // note that we cast to long first to prevent overflows; this cast is OK since we are only interested in the lower word

            typeinfo.GetRefTypeInfo(reftype, out custtypeinfo);

            if (custtypeinfo != null)
            {
                String strName, strDoc, strHelp;
                int id;
                custtypeinfo.GetDocumentation(-1, out strName, out strDoc, out id, out strHelp);
                return strName;
            }
            return "UnknownCustomtype";
        }
开发者ID:40a,项目名称:PowerShell,代码行数:22,代码来源:ComUtil.cs


注:本文中的System.Runtime.InteropServices.ComTypes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。