Freigeben über


TypeLibFuncAttribute-Klasse

Enthält die FUNCFLAGS, die ursprünglich aus der COM-Typbibliothek für diese Methode importiert wurden.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Method, Inherited:=False)> _
Public NotInheritable Class TypeLibFuncAttribute
    Inherits Attribute
'Usage
Dim instance As TypeLibFuncAttribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets.Method, Inherited=false)] 
public sealed class TypeLibFuncAttribute : Attribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets::Method, Inherited=false)] 
public ref class TypeLibFuncAttribute sealed : public Attribute
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Method, Inherited=false) */ 
public final class TypeLibFuncAttribute extends Attribute
ComVisibleAttribute(true) 
AttributeUsageAttribute(AttributeTargets.Method, Inherited=false) 
public final class TypeLibFuncAttribute extends Attribute

Hinweise

Type Library Importer-Tool (Tlbimp.exe) wendet dieses Attribut auf Methoden an.

Das Attribut wird beim Importieren einer Typbibliothek angewendet und darf nicht geändert werden. Es wird nur angewendet, wenn die FUNCFLAGS der Methode als ungleich 0 ausgewertet werden. Dieses Attribut ist für Tools bestimmt, die die Festlegungen der ursprünglichen FUNCFLAGS kennen müssen. Von der Common Language Runtime wird dieses Attribut nicht verwendet.

Beispiel

Im folgenden Beispiel wird veranschaulicht, wie der TypeLibFuncAttribute-Wert einer Methode abgerufen wird.

Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

Module C
    Public Function IsHiddenMethod(ByVal mi As MethodInfo) As Boolean
        Dim MethodAttributes As Object() = mi.GetCustomAttributes(GetType(TypeLibFuncAttribute), True)

        If MethodAttributes.Length > 0 Then
            Dim tlf As TypeLibFuncAttribute = MethodAttributes(0)
            Dim flags As TypeLibFuncFlags = tlf.Value
            Return (flags & TypeLibFuncFlags.FHidden) > 0
        End If
        Return False
    End Function
End Module
using System;
using System.Reflection;
using System.Runtime.InteropServices;

namespace C
{
    class ClassC    
    {
        public static bool IsHiddenMethod( MethodInfo mi )
        {
            object[] MethodAttributes = mi.GetCustomAttributes( typeof( TypeLibFuncAttribute ), true);
        
            if( MethodAttributes.Length > 0 )
            {
                TypeLibFuncAttribute tlf = ( TypeLibFuncAttribute )MethodAttributes[0];
                TypeLibFuncFlags  flags = tlf.Value;
                return ( flags & TypeLibFuncFlags.FHidden ) != 0; 
            }
            return false;
        }
    }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

ref class ClassC
{
private:
   static bool IsHiddenMethod( MethodInfo^ mi )
   {
      array<Object^>^MethodAttributes = mi->GetCustomAttributes( TypeLibFuncAttribute::typeid, true );
      if ( MethodAttributes->Length > 0 )
      {
         TypeLibFuncAttribute^ tlf = dynamic_cast<TypeLibFuncAttribute^>(MethodAttributes[ 0 ]);
         TypeLibFuncFlags flags = tlf->Value;
         return (flags & TypeLibFuncFlags::FHidden) != (TypeLibFuncFlags)0;
      }

      return false;
   }
};
import System.*;
import System.Reflection.*;
import System.Runtime.InteropServices.*;

class ClassC
{
    public static boolean IsHiddenMethod(MethodInfo mi)
    {
        Object methodAttributes[] 
            = mi.GetCustomAttributes(TypeLibFuncAttribute.class.ToType(), true);

        if (methodAttributes.length > 0) {
            TypeLibFuncAttribute tlf 
                = (TypeLibFuncAttribute)(methodAttributes.get_Item(0));
            TypeLibFuncFlags flags = tlf.get_Value();

            return (int)(flags & TypeLibFuncFlags.FHidden) != 0;
        }
        return false;
    } //IsHiddenMethod
} //ClassC

Vererbungshierarchie

System.Object
   System.Attribute
    System.Runtime.InteropServices.TypeLibFuncAttribute

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

TypeLibFuncAttribute-Member
System.Runtime.InteropServices-Namespace

Weitere Ressourcen

Type Library Importer-Tool (Tlbimp.exe)