Marshal.GetDelegateForFunctionPointer Método

Definición

Sobrecargas

GetDelegateForFunctionPointer(IntPtr, Type)
Obsoletos.

Convierte un puntero a función no administrada en un delegado.

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Convierte un puntero a función no administrada en un delegado de un tipo especificado.

GetDelegateForFunctionPointer(IntPtr, Type)

Precaució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

Convierte un puntero a función no administrada en un delegado.

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

Parámetros

ptr
IntPtr

nativeint

Puntero a función no administrada que se va a convertir.

t
Type

Tipo del delegado que se va a devolver.

Devoluciones

Instancia de delegado que se puede convertir al tipo de delegado adecuado.

Atributos

Excepciones

El parámetro t no es un delegado o es genérico.

El parámetro ptr es null.

o bien

El parámetro t es null.

Comentarios

Puede usar los GetDelegateForFunctionPointer métodos y GetFunctionPointerForDelegate para serializar delegados en ambas direcciones. Con GetDelegateForFunctionPointer, ptr se importa como .System.IntPtr System.IntPtr Se puede obtener para un delegado administrado llamando GetFunctionPointerForDelegate a y pasando como parámetro; a continuación, se puede llamar desde dentro del método no administrado. Tenga en cuenta que el serializador de parámetros también puede serializar punteros de función a delegados en .NET Framework 2.0 y versiones posteriores.

ptr se convierte en un delegado que invoca el método no administrado mediante la convención de llamada de plataforma predeterminada. Puede establecer la convención de llamada aplicando al UnmanagedFunctionPointerAttribute delegado .

El GetDelegateForFunctionPointer método tiene las siguientes restricciones:

  • Los genéricos no se admiten en escenarios de interoperabilidad.

  • Puede usar este método solo para punteros de función puros no administrados.

  • No puede usar este método con punteros de función obtenidos a través de C++.

Se aplica a

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Convierte un puntero a función no administrada en un delegado de un tipo especificado.

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

Parámetros de tipo

TDelegate

Tipo del delegado que se va a devolver.

Parámetros

ptr
IntPtr

nativeint

Puntero a función no administrada que se va a convertir.

Devoluciones

TDelegate

Una instancia del tipo de delegado especificado.

Atributos

Excepciones

El parámetro genérico TDelegate no es un delegado o es un tipo genérico abierto.

El parámetro ptr es null.

Comentarios

Puede usar los GetDelegateForFunctionPointer<TDelegate>(IntPtr) métodos y GetFunctionPointerForDelegate<TDelegate>(TDelegate) para serializar delegados en ambas direcciones.

ptr se convierte en un delegado que invoca el método no administrado mediante la convención de llamada de plataforma predeterminada. Puede establecer la convención de llamada aplicando al UnmanagedFunctionPointerAttribute delegado .

El GetDelegateForFunctionPointer<TDelegate>(IntPtr) método tiene las siguientes restricciones:

  • Los genéricos no se admiten en escenarios de interoperabilidad.

  • Puede usar este método solo para punteros de función puros no administrados.

  • No puede usar este método con punteros de función obtenidos a través de C++.

Se aplica a