Marshal.GetDelegateForFunctionPointer Metoda

Definicja

Przeciążenia

Nazwa Opis
GetDelegateForFunctionPointer(IntPtr, Type)
Przestarzałe.

Konwertuje wskaźnik funkcji niezarządzanej na delegata.

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Konwertuje wskaźnik funkcji niezarządzanej na delegat określonego typu.

GetDelegateForFunctionPointer(IntPtr, Type)

Uwaga

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

Konwertuje wskaźnik funkcji niezarządzanej na delegata.

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

Wskaźnik funkcji niezarządzanej do przekonwertowania.

t
Type

Typ delegata, który ma zostać zwrócony.

Zwraca

Wystąpienie delegata, które można rzutować do odpowiedniego typu delegata.

Atrybuty

Wyjątki

Parametr t nie jest delegatem lub jest ogólny.

Parametr ptr jest null.

— lub —

Parametr t jest null.

Uwagi

Metody i GetFunctionPointerForDelegate umożliwiają GetDelegateForFunctionPointer przeprowadzanie marshalingu delegatów w obu kierunkach. Element z GetDelegateForFunctionPointerelementem ptr jest importowany jako element System.IntPtr. Element System.IntPtr można uzyskać dla zarządzanego delegata przez wywołanie GetFunctionPointerForDelegate i przekazanie go jako parametru. Następnie można go wywołać z wewnątrz metody niezarządzanej. Należy pamiętać, że marshaler parametrów może również marshalować wskaźniki funkcji do delegatów.

ptr element jest konwertowany na delegata, który wywołuje metodę niezarządzaną przy użyciu domyślnej konwencji wywoływania platformy. Konwencję wywoływania można ustawić, stosując element UnmanagedFunctionPointerAttribute do delegata.

Metoda GetDelegateForFunctionPointer ma następujące ograniczenia:

  • Typy ogólne nie są obsługiwane w scenariuszach międzyoperacyjności.
  • Tej metody można używać tylko dla czystych wskaźników funkcji niezarządzanych.
  • Nie można użyć tej metody ze wskaźnikami funkcji uzyskanymi za pośrednictwem języka C++.

Dotyczy

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Konwertuje wskaźnik funkcji niezarządzanej na delegat określonego 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 delegata do zwrócenia.

Parametry

ptr
IntPtr

nativeint

Wskaźnik funkcji niezarządzanej do konwersji.

Zwraca

TDelegate

Wystąpienie określonego typu delegata.

Atrybuty

Wyjątki

Parametr TDelegate ogólny nie jest pełnomocnikiem lub jest otwartym typem ogólnym.

Parametr ptr jest null.

Uwagi

Metody i GetFunctionPointerForDelegate<TDelegate>(TDelegate) umożliwiają GetDelegateForFunctionPointer<TDelegate>(IntPtr) przeprowadzanie marshalingu delegatów w obu kierunkach.

ptr element jest konwertowany na delegata, który wywołuje metodę niezarządzaną przy użyciu domyślnej konwencji wywoływania platformy. Konwencję wywoływania można ustawić, stosując element UnmanagedFunctionPointerAttribute do delegata.

Metoda GetDelegateForFunctionPointer<TDelegate>(IntPtr) ma następujące ograniczenia:

  • Typy ogólne nie są obsługiwane w scenariuszach międzyoperacyjności.
  • Tej metody można używać tylko dla czystych wskaźników funkcji niezarządzanych.
  • Nie można użyć tej metody ze wskaźnikami funkcji uzyskanymi za pośrednictwem języka C++.

Dotyczy