Marshal.GetDelegateForFunctionPointer Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Přetížení
| Name | Description |
|---|---|
| GetDelegateForFunctionPointer(IntPtr, Type) |
Zastaralé.
Převede nespravovaný ukazatel funkce na delegáta. |
| GetDelegateForFunctionPointer<TDelegate>(IntPtr) |
Převede nespravovaný ukazatel funkce na delegáta zadaného typu. |
GetDelegateForFunctionPointer(IntPtr, Type)
- Zdroj:
- Marshal.cs
- Zdroj:
- Marshal.cs
- 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 nespravovaný ukazatel 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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the delegate might not be available. Use the GetDelegateForFunctionPointer<TDelegate> overload instead.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the delegate might not be available. Use the GetDelegateForFunctionPointer<TDelegate> overload instead.")>]
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ý se má převést.
- t
- Type
Typ delegáta, který se má vrátit.
Návraty
Instance delegáta, která může být přetypován na příslušný typ delegáta.
- Atributy
Výjimky
Parametr t není delegát nebo je obecný.
Poznámky
K zařazování delegátů v obou směrech můžete použít GetDelegateForFunctionPointer metody a GetFunctionPointerForDelegate metody. S GetDelegateForFunctionPointer, ptr je importován System.IntPtrjako . Spravovaného System.IntPtr delegáta lze získat voláním GetFunctionPointerForDelegate a předáním jako parametru. Potom ho lze volat z nespravované metody. Všimněte si, že parametr marshaler může také zařazovací ukazatele funkce na delegáty.
ptr je převeden na delegáta, který vyvolá nespravovanou metodu pomocí výchozí konvence volání platformy. Konvenci volání můžete nastavit použitím UnmanagedFunctionPointerAttribute delegáta.
Metoda GetDelegateForFunctionPointer má následující omezení:
- Obecné typy nejsou podporovány ve scénářích spolupráce.
- Tuto metodu můžete použít pouze pro čistě nespravované ukazatele funkce.
- Tuto metodu nelze použít s ukazateli funkcí získanými prostřednictvím jazyka C++.
Platí pro
GetDelegateForFunctionPointer<TDelegate>(IntPtr)
- Zdroj:
- Marshal.cs
- Zdroj:
- Marshal.cs
- Zdroj:
- Marshal.cs
- Zdroj:
- Marshal.cs
- Zdroj:
- Marshal.cs
Převede nespravovaný ukazatel 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
Nespravovaný ukazatel funkce, který chcete převést.
Návraty
Instance zadaného typu delegáta.
- Atributy
Výjimky
Obecný TDelegate parametr není delegát nebo je to 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) metody.
ptr je převeden na delegáta, který vyvolá nespravovanou metodu pomocí výchozí konvence volání platformy. Konvenci volání můžete nastavit použitím UnmanagedFunctionPointerAttribute delegáta.
Metoda GetDelegateForFunctionPointer<TDelegate>(IntPtr) má následující omezení:
- Obecné typy nejsou podporovány ve scénářích spolupráce.
- Tuto metodu můžete použít pouze pro čistě nespravované ukazatele funkce.
- Tuto metodu nelze použít s ukazateli funkcí získanými prostřednictvím jazyka C++.