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


C# ITypeInfo.GetTypeAttr方法代码示例

本文整理汇总了C#中ITypeInfo.GetTypeAttr方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeInfo.GetTypeAttr方法的具体用法?C# ITypeInfo.GetTypeAttr怎么用?C# ITypeInfo.GetTypeAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITypeInfo的用法示例。


在下文中一共展示了ITypeInfo.GetTypeAttr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTypeAttr

 public IntPtr GetTypeAttr(ITypeInfo typeInfo)
 {
     if (typeInfo == null) throw new ArgumentNullException(nameof(typeInfo));
     IntPtr ret;
     typeInfo.GetTypeAttr(out ret);
     return ret;
 }
开发者ID:dbremner,项目名称:clrinterop,代码行数:7,代码来源:DefaultDaemon.cs

示例2: GetTypeAttr

        public static TYPEATTR GetTypeAttr(ITypeInfo typeInfo)
        {
            IntPtr ppAttr;
            typeInfo.GetTypeAttr(out ppAttr);
            TYPEATTR typeAttr = (TYPEATTR)Marshal.PtrToStructure(ppAttr, typeof(TYPEATTR));
            typeInfo.ReleaseTypeAttr(ppAttr);

            return typeAttr;
        }
开发者ID:cstrahan,项目名称:COMExplorer,代码行数:9,代码来源:COMUtil.cs

示例3: GetTypeAttrForTypeInfo

 internal static void GetTypeAttrForTypeInfo(ITypeInfo typeInfo, out System.Runtime.InteropServices.ComTypes.TYPEATTR typeAttr)
 {
     IntPtr zero = IntPtr.Zero;
     typeInfo.GetTypeAttr(out zero);
     if (zero == IntPtr.Zero)
     {
         throw new COMException(Microsoft.Build.Shared.ResourceUtilities.FormatResourceString("ResolveComReference.CannotRetrieveTypeInformation", new object[0]));
     }
     try
     {
         typeAttr = (System.Runtime.InteropServices.ComTypes.TYPEATTR) Marshal.PtrToStructure(zero, typeof(System.Runtime.InteropServices.ComTypes.TYPEATTR));
     }
     finally
     {
         typeInfo.ReleaseTypeAttr(zero);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ComReference.cs

示例4: ProcessTypeInfo

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Processes one type info. We get the necessary information from the type library
		/// and also from the registry.
		/// </summary>
		/// <param name="parent">The parent element.</param>
		/// <param name="tlbGuid">The guid of the type library.</param>
		/// <param name="typeInfo">The type info.</param>
		/// ------------------------------------------------------------------------------------
		private void ProcessTypeInfo(XmlNode parent, Guid tlbGuid, ITypeInfo typeInfo)
		{
// ReSharper disable EmptyGeneralCatchClause
			try
			{
				IntPtr pTypeAttr;
				typeInfo.GetTypeAttr(out pTypeAttr);
				var typeAttr = (TYPEATTR)
					System.Runtime.InteropServices.Marshal.PtrToStructure(pTypeAttr, typeof(TYPEATTR));
				typeInfo.ReleaseTypeAttr(pTypeAttr);
				if (typeAttr.typekind == TYPEKIND.TKIND_COCLASS)
				{
					string keyString = string.Format(@"CLSID\{{{0}}}", typeAttr.guid);
					RegistryKey typeKey = Registry.ClassesRoot.OpenSubKey(keyString);
					if (typeKey == null)
						return;

					RegistryKey inprocServer = typeKey.OpenSubKey("InprocServer32");
					if (inprocServer == null)
						return;

					// Try to get the file element for the server
					var bldr = new StringBuilder(255);
					GetLongPathName((string)inprocServer.GetValue(null), bldr, 255);
					string serverFullPath = bldr.ToString();
					string server = Path.GetFileName(serverFullPath);
					if (!File.Exists(serverFullPath) &&
						!File.Exists(Path.Combine(m_BaseDirectory, server)))
					{
						if (!m_NonExistingServers.Contains(server))
						{
							Console.WriteLine("{0} is referenced in the TLB but is not in current directory", server);
							m_NonExistingServers.Add(server);
						}
						return;
					}

					XmlElement file = GetOrCreateFileNode(parent, server);
					//// Check to see that the DLL we're processing is really the DLL that can
					//// create this class. Otherwise we better not claim that we know how to do it!
					//if (keyString == null || keyString == string.Empty ||
					//    server.ToLower() != Path.GetFileName(m_FileName))
					//{
					//    return;
					//}

					var threadingModel = (string)inprocServer.GetValue("ThreadingModel");
					var progIdKey = typeKey.OpenSubKey("ProgID");
					if (progIdKey == null)
						return;
					var progId = (string)progIdKey.GetValue(null);

					XmlElement elem;
					if (!m_CoClasses.ContainsKey(progId))
					{
						// <comClass clsid="{2f0fccc2-c160-11d3-8da2-005004defec4}" threadingModel="Apartment"
						//		tlbid="{2f0fccc0-c160-11d3-8da2-005004defec4}" progid="FieldWorks.FwXmlData" />
						elem = m_Doc.CreateElement("comClass", UrnAsmv1);
						elem.SetAttribute("clsid", string.Format("{{{0}}}", typeAttr.guid));
						elem.SetAttribute("threadingModel", threadingModel);
						elem.SetAttribute("tlbid", string.Format("{{{0}}}", tlbGuid));
						elem.SetAttribute("progid", progId);
						m_CoClasses.Add(progId, elem);
						XmlNode oldChild = file.SelectSingleNode(string.Format("comClass[clsid='{{{0}}}']",
							typeAttr.guid));
						if (oldChild != null)
							file.ReplaceChild(elem, oldChild);
						else
							file.AppendChild(elem);
					}

					Debug.WriteLine(string.Format(@"Coclass: clsid=""{0}"", threadingModel=""{1}"", tlbid=""{2}"", progid=""{3}""",
						typeAttr.guid, threadingModel, tlbGuid, progId));

				}
			}
			catch
			{
				// just ignore any errors
			}
// ReSharper restore EmptyGeneralCatchClause
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:91,代码来源:RegFreeCreator.cs

示例5: ProcessTypeInfo

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Processes one type info. We get the necessary information from the type library
		/// and also from the registry.
		/// </summary>
		/// <param name="parent">The parent element.</param>
		/// <param name="tlbGuid">The guid of the type library.</param>
		/// <param name="typeInfo">The type info.</param>
		/// ------------------------------------------------------------------------------------
		private void ProcessTypeInfo(XmlNode parent, Guid tlbGuid, ITypeInfo typeInfo)
		{
			try
			{
				IntPtr pTypeAttr;
				typeInfo.GetTypeAttr(out pTypeAttr);
				var typeAttr = (TYPEATTR)Marshal.PtrToStructure(pTypeAttr, typeof(TYPEATTR));
				typeInfo.ReleaseTypeAttr(pTypeAttr);
				if (typeAttr.typekind == TYPEKIND.TKIND_COCLASS)
				{
					var clsId = typeAttr.guid.ToString("B");
					string keyString = string.Format(@"CLSID\{0}", clsId);
					RegistryKey typeKey = Registry.ClassesRoot.OpenSubKey(keyString);
					if (typeKey == null)
						return;

					RegistryKey inprocServer = typeKey.OpenSubKey("InprocServer32");
					if (inprocServer == null)
						return;

					// Try to get the file element for the server
					var bldr = new StringBuilder(255);
					RegHelper.GetLongPathName((string)inprocServer.GetValue(null), bldr, 255);
					string serverFullPath = bldr.ToString();
					string server = Path.GetFileName(serverFullPath);
					if (!File.Exists(serverFullPath) &&
						!File.Exists(Path.Combine(_baseDirectory, server)))
					{
						if (!_nonExistingServers.Contains(server))
						{
							_log.LogMessage(MessageImportance.Low, "{0} is referenced in the TLB but is not in current directory", server);
							_nonExistingServers.Add(server);
						}
						return;
					}

					XmlElement file = GetOrCreateFileNode(parent, server);
					//// Check to see that the DLL we're processing is really the DLL that can
					//// create this class. Otherwise we better not claim that we know how to do it!
					//if (keyString == null || keyString == string.Empty ||
					//    server.ToLower() != Path.GetFileName(m_FileName))
					//{
					//    return;
					//}

					if (!_coClasses.ContainsKey(clsId))
					{
						var description = (string)typeKey.GetValue(string.Empty);
						var threadingModel = (string)inprocServer.GetValue("ThreadingModel");
						var progId = GetDefaultValueForKey(typeKey, "ProgID");
						AddOrReplaceCoClass(file, clsId, threadingModel, description, tlbGuid.ToString("B"), progId);
						_log.LogMessage(MessageImportance.Low, string.Format(@"Coclass: clsid=""{0}"", threadingModel=""{1}"", tlbid=""{2}"", progid=""{3}""",
							clsId, threadingModel, tlbGuid, progId));
					}
				}
			}
			catch(Exception e)
			{
				_log.LogMessage(MessageImportance.High, "Failed to process the type info for {0}", tlbGuid);
				_log.LogMessage(MessageImportance.High, e.StackTrace);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:71,代码来源:RegFreeCreator.cs

示例6: GetTypeAttrForTypeInfo

        /// <summary>
        /// Helper method for retrieving type attributes for a given type info
        /// </summary>
        /// <param name="typeInfo"></param>
        /// <param name="typeAttr"></param>
        /// <returns></returns>
        internal static void GetTypeAttrForTypeInfo(ITypeInfo typeInfo, out TYPEATTR typeAttr)
        {
            IntPtr pAttrs = IntPtr.Zero;
            typeInfo.GetTypeAttr(out pAttrs);

            // GetTypeAttr should never return null, this is just to be safe
            if (pAttrs == IntPtr.Zero)
            {
                throw new COMException(
                    ResourceUtilities.FormatResourceString("ResolveComReference.CannotRetrieveTypeInformation"));
            }

            try
            {
                typeAttr = (TYPEATTR)Marshal.PtrToStructure(pAttrs, typeof(TYPEATTR));
            }
            finally
            {
                typeInfo.ReleaseTypeAttr(pAttrs);
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:27,代码来源:ComReference.cs

示例7: GetTypeAttr_Proxy

 private static IntPtr GetTypeAttr_Proxy(ITypeInfo typeInfo)
 {
     IntPtr typeAttr;
     typeInfo.GetTypeAttr(out typeAttr);
     return typeAttr;
 }
开发者ID:dbremner,项目名称:clrinterop,代码行数:6,代码来源:FormDaemon.cs

示例8: GetTypeAttr

 internal static System.Runtime.InteropServices.ComTypes.TYPEATTR GetTypeAttr(ITypeInfo typeinfo)
 {
     IntPtr ptr;
     typeinfo.GetTypeAttr(out ptr);
     System.Runtime.InteropServices.ComTypes.TYPEATTR typeattr = (System.Runtime.InteropServices.ComTypes.TYPEATTR) Marshal.PtrToStructure(ptr, typeof(System.Runtime.InteropServices.ComTypes.TYPEATTR));
     typeinfo.ReleaseTypeAttr(ptr);
     return typeattr;
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:ComTypeInfo.cs


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