Marshal.GetDelegateForFunctionPointer Metoda

Definicja

Przeciążenia

GetDelegateForFunctionPointer(IntPtr, Type)
Przestarzałe.

Konwertuje wskaźnik funkcji niezarządzanej na delegata.

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

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

GetDelegateForFunctionPointer(IntPtr, Type)

Źródło:
Marshal.cs
Źródło:
Marshal.cs
Źródło:
Marshal.cs

Przestroga

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, który ma zostać przekonwertowany.

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 ma wartość null.

-lub-

Parametr t ma wartość null.

Uwagi

Metody i GetFunctionPointerForDelegate umożliwiają GetDelegateForFunctionPointer przeprowadzanie marshalingu delegatów w obu kierunkach. ptr Element z GetDelegateForFunctionPointerelementem 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. Można go następnie wywołać z wewnątrz metody niezarządzanej. Należy pamiętać, że marshaler parametrów może również marshaling wskaźników funkcji do delegatów w .NET Framework 2.0 i nowszych wersjach.

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 niezarządzanych wskaźników funkcji.

  • Nie można użyć tej metody ze wskaźnikami funkcji uzyskanymi za pośrednictwem języka C++.

Dotyczy

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Źródło:
Marshal.cs
Źródło:
Marshal.cs
Źródło:
Marshal.cs

Konwertuje wskaźnik funkcji niezarządzanej na delegata 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 delegatem lub jest otwartym typem ogólnym.

Parametr ptr ma wartość 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 niezarządzanych wskaźników funkcji.

  • Nie można użyć tej metody ze wskaźnikami funkcji uzyskanymi za pośrednictwem języka C++.

Dotyczy