本文整理汇总了C#中ITypeInfo.ReleaseTypeAttr方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeInfo.ReleaseTypeAttr方法的具体用法?C# ITypeInfo.ReleaseTypeAttr怎么用?C# ITypeInfo.ReleaseTypeAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeInfo
的用法示例。
在下文中一共展示了ITypeInfo.ReleaseTypeAttr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: ReleaseTypeAttr
public void ReleaseTypeAttr(ITypeInfo typeInfo, IntPtr typeAttr)
{
if (typeInfo == null) throw new ArgumentNullException(nameof(typeInfo));
typeInfo.ReleaseTypeAttr(typeAttr);
}
示例3: 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
}
示例4: 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);
}
}
示例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);
}
}
示例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);
}
}
示例7: ReleaseTypeAttr_Proxy
private static void ReleaseTypeAttr_Proxy(ITypeInfo typeInfo, IntPtr typeAttr)
{
typeInfo.ReleaseTypeAttr(typeAttr);
}
示例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;
}