Marshal.GetDelegateForFunctionPointer Metoda

Definice

Přetížení

GetDelegateForFunctionPointer(IntPtr, Type)
Zastaralé.

Převede ukazatel nespravované funkce na delegáta.

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Převede ukazatel nespravované funkce na delegáta zadaného typu.

GetDelegateForFunctionPointer(IntPtr, Type)

Zdroj:
Marshal.cs
Zdroj:
Marshal.cs
Zdroj:
Marshal.cs

Upozornění

GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521

Převede ukazatel nespravované funkce na delegáta.

public:
 static Delegate ^ GetDelegateForFunctionPointer(IntPtr ptr, Type ^ t);
[System.Obsolete("GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521")]
[System.Security.SecurityCritical]
public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t);
public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t);
[System.Security.SecurityCritical]
public static Delegate GetDelegateForFunctionPointer (IntPtr ptr, Type t);
[<System.Obsolete("GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521")>]
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
Public Shared Function GetDelegateForFunctionPointer (ptr As IntPtr, t As Type) As Delegate

Parametry

ptr
IntPtr

nativeint

Ukazatel nespravované funkce, který má být převeden.

t
Type

Typ delegáta, který se má vrátit.

Návraty

Instance delegáta, který lze přetypovat na příslušný typ delegáta.

Atributy

Výjimky

Parametr t není delegát nebo je obecný.

Parametr ptr je null.

-nebo-

Parametr t je null.

Poznámky

K zařazování delegátů v obou směrech můžete použít GetDelegateForFunctionPointer metody a GetFunctionPointerForDelegate . Pomocí GetDelegateForFunctionPointerpříkazu se ptr naimportuje jako System.IntPtr. Pro System.IntPtr spravovaného delegáta lze získat voláním GetFunctionPointerForDelegate a předáním jako parametru; pak může být volána z nespravované metody. Všimněte si, že zařazování parametrů může také zařaďte ukazatele na funkce na delegáty v rozhraní .NET Framework 2.0 a novějších verzích.

ptr se převede na delegáta, který vyvolá nespravovanou metodu pomocí výchozí konvence volání platformy. Konvenci volání můžete nastavit tak, že na delegáta použijete UnmanagedFunctionPointerAttribute .

Metoda GetDelegateForFunctionPointer má následující omezení:

  • Obecné typy nejsou podporovány ve scénářích zprostředkovatele komunikace.

  • Tuto metodu můžete použít pouze pro čistě nespravované ukazatele na funkce.

  • Tuto metodu nelze použít s ukazateli na funkce získanými prostřednictvím jazyka C++.

Platí pro

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Zdroj:
Marshal.cs
Zdroj:
Marshal.cs
Zdroj:
Marshal.cs

Převede ukazatel nespravované funkce na delegáta zadaného typu.

public:
generic <typename TDelegate>
 static TDelegate GetDelegateForFunctionPointer(IntPtr ptr);
[System.Security.SecurityCritical]
public static TDelegate GetDelegateForFunctionPointer<TDelegate> (IntPtr ptr);
public static TDelegate GetDelegateForFunctionPointer<TDelegate> (IntPtr ptr);
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint -> 'Delegate
static member GetDelegateForFunctionPointer : nativeint -> 'Delegate
Public Shared Function GetDelegateForFunctionPointer(Of TDelegate) (ptr As IntPtr) As TDelegate

Parametry typu

TDelegate

Typ delegáta, který se má vrátit.

Parametry

ptr
IntPtr

nativeint

Ukazatel nespravované funkce, který chcete převést.

Návraty

TDelegate

Instance zadaného typu delegáta.

Atributy

Výjimky

Obecný TDelegate parametr není delegátem nebo jde o otevřený obecný typ.

Parametr ptr je null.

Poznámky

K zařazování delegátů v obou směrech můžete použít GetDelegateForFunctionPointer<TDelegate>(IntPtr) metody a GetFunctionPointerForDelegate<TDelegate>(TDelegate) .

ptr se převede na delegáta, který vyvolá nespravovanou metodu pomocí výchozí konvence volání platformy. Konvenci volání můžete nastavit tak, že na delegáta použijete UnmanagedFunctionPointerAttribute .

Metoda GetDelegateForFunctionPointer<TDelegate>(IntPtr) má následující omezení:

  • Obecné typy nejsou podporovány ve scénářích zprostředkovatele komunikace.

  • Tuto metodu můžete použít pouze pro čistě nespravované ukazatele na funkce.

  • Tuto metodu nelze použít s ukazateli na funkce získanými prostřednictvím jazyka C++.

Platí pro