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í
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ý.
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
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
Váš názor
https://aka.ms/ContentUserFeedback.
Připravujeme: V průběhu roku 2024 budeme postupně vyřazovat problémy z GitHub coby mechanismus zpětné vazby pro obsah a nahrazovat ho novým systémem zpětné vazby. Další informace naleznete v tématu:Odeslat a zobrazit názory pro