Marshal.GetDelegateForFunctionPointer Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
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.
Uwagi
Metody i GetFunctionPointerForDelegate umożliwiają GetDelegateForFunctionPointer przeprowadzanie marshalingu delegatów w obu kierunkach. Za pomocą GetDelegateForFunctionPointerpolecenia element jest importowany jako System.IntPtr. ptr
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 w wersji .NET Framework 2.0 i nowszych.
ptr
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 z 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
Wystąpienie określonego typu delegata.
- Atrybuty
Wyjątki
Parametr TDelegate
ogólny nie jest delegatem lub jest otwartym typem ogólnym.
Parametr ptr
to null
.
Uwagi
Metody i GetFunctionPointerForDelegate<TDelegate>(TDelegate) umożliwiają GetDelegateForFunctionPointer<TDelegate>(IntPtr) przeprowadzanie marshalingu delegatów w obu kierunkach.
ptr
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 z wskaźnikami funkcji uzyskanymi za pośrednictwem języka C++.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla