Marshal.PtrToStructure Método

Definición

Serializa los datos de un bloque de memoria no administrado a un objeto administrado.

Sobrecargas

Nombre Description
PtrToStructure(IntPtr, Object)
Obsoletos.

Serializa los datos de un bloque de memoria no administrado a un objeto administrado.

PtrToStructure(IntPtr, Type)
Obsoletos.

Serializa los datos de un bloque de memoria no administrado a un objeto administrado recién asignado del tipo especificado.

PtrToStructure<T>(IntPtr)

Serializa los datos de un bloque de memoria no administrado a un objeto administrado recién asignado del tipo especificado por un parámetro de tipo genérico.

PtrToStructure<T>(IntPtr, T)

Serializa los datos de un bloque de memoria no administrado a un objeto administrado del tipo especificado.

PtrToStructure(IntPtr, Object)

Precaución

PtrToStructure(IntPtr, Object) may be unavailable in future releases. Instead, use PtrToStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296512

Serializa los datos de un bloque de memoria no administrado a un objeto administrado.

public:
 static void PtrToStructure(IntPtr ptr, System::Object ^ structure);
[System.Obsolete("PtrToStructure(IntPtr, Object) may be unavailable in future releases. Instead, use PtrToStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296512")]
[System.Security.SecurityCritical]
public static void PtrToStructure(IntPtr ptr, object structure);
public static void PtrToStructure(IntPtr ptr, object structure);
[System.Runtime.InteropServices.ComVisible(true)]
public static void PtrToStructure(IntPtr ptr, object structure);
[System.Security.SecurityCritical]
[System.Runtime.InteropServices.ComVisible(true)]
public static void PtrToStructure(IntPtr ptr, object structure);
[System.Security.SecurityCritical]
public static void PtrToStructure(IntPtr ptr, object structure);
[<System.Obsolete("PtrToStructure(IntPtr, Object) may be unavailable in future releases. Instead, use PtrToStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296512")>]
[<System.Security.SecurityCritical>]
static member PtrToStructure : nativeint * obj -> unit
static member PtrToStructure : nativeint * obj -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
static member PtrToStructure : nativeint * obj -> unit
[<System.Security.SecurityCritical>]
[<System.Runtime.InteropServices.ComVisible(true)>]
static member PtrToStructure : nativeint * obj -> unit
[<System.Security.SecurityCritical>]
static member PtrToStructure : nativeint * obj -> unit
Public Shared Sub PtrToStructure (ptr As IntPtr, structure As Object)

Parámetros

ptr
IntPtr

nativeint

Puntero a un bloque de memoria no administrado.

structure
Object

Objeto al que se van a copiar los datos. Debe ser una instancia de una clase con formato.

Atributos

Excepciones

El diseño de la estructura no es secuencial ni explícito.

O bien

Structure es un tipo de valor boxed.

Comentarios

PtrToStructure a menudo es necesario en la interoperabilidad COM e invocación de plataforma cuando los parámetros de estructura se representan como un System.IntPtr valor. No puede usar este método de sobrecarga con tipos de valor. Si el ptr parámetro es igual IntPtr.Zeroa , null se devolverá.

Se aplica a

PtrToStructure(IntPtr, Type)

Precaución

PtrToStructure(IntPtr, Type) may be unavailable in future releases. Instead, use PtrToStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296513

Serializa los datos de un bloque de memoria no administrado a un objeto administrado recién asignado del tipo especificado.

public:
 static System::Object ^ PtrToStructure(IntPtr ptr, Type ^ structureType);
[System.Obsolete("PtrToStructure(IntPtr, Type) may be unavailable in future releases. Instead, use PtrToStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296513")]
[System.Security.SecurityCritical]
public static object PtrToStructure(IntPtr ptr, Type structureType);
public static object PtrToStructure(IntPtr ptr, Type structureType);
[System.Runtime.InteropServices.ComVisible(true)]
public static object PtrToStructure(IntPtr ptr, Type structureType);
[System.Security.SecurityCritical]
[System.Runtime.InteropServices.ComVisible(true)]
public static object PtrToStructure(IntPtr ptr, Type structureType);
[System.Security.SecurityCritical]
public static object PtrToStructure(IntPtr ptr, Type structureType);
[<System.Obsolete("PtrToStructure(IntPtr, Type) may be unavailable in future releases. Instead, use PtrToStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296513")>]
[<System.Security.SecurityCritical>]
static member PtrToStructure : nativeint * Type -> obj
static member PtrToStructure : nativeint * Type -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
static member PtrToStructure : nativeint * Type -> obj
[<System.Security.SecurityCritical>]
[<System.Runtime.InteropServices.ComVisible(true)>]
static member PtrToStructure : nativeint * Type -> obj
[<System.Security.SecurityCritical>]
static member PtrToStructure : nativeint * Type -> obj
Public Shared Function PtrToStructure (ptr As IntPtr, structureType As Type) As Object

Parámetros

ptr
IntPtr

nativeint

Puntero a un bloque de memoria no administrado.

structureType
Type

Tipo de objeto que se va a crear. Este objeto debe representar una clase con formato o una estructura.

Devoluciones

Objeto administrado que contiene los datos a los que apunta el ptr parámetro .

Atributos

Excepciones

El diseño del structureType parámetro no es secuencial o explícito.

O bien

El structureType parámetro es una definición de tipo genérico.

structureType es null.

La clase especificada por structureType no tiene un constructor sin parámetros accesible.

Comentarios

PtrToStructure a menudo es necesario en la interoperabilidad COM e invocación de plataforma cuando los parámetros de estructura se representan como un System.IntPtr valor. Puede pasar un tipo de valor a este método de sobrecarga. En este caso, el objeto devuelto es una instancia boxed. Si el ptr parámetro es igual IntPtr.Zeroa , null se devolverá.

Consulte también

Se aplica a

PtrToStructure<T>(IntPtr)

Serializa los datos de un bloque de memoria no administrado a un objeto administrado recién asignado del tipo especificado por un parámetro de tipo genérico.

public:
generic <typename T>
 static T PtrToStructure(IntPtr ptr);
[System.Security.SecurityCritical]
public static T PtrToStructure<T>(IntPtr ptr);
public static T PtrToStructure<T>(IntPtr ptr);
[<System.Security.SecurityCritical>]
static member PtrToStructure : nativeint -> 'T
static member PtrToStructure : nativeint -> 'T
Public Shared Function PtrToStructure(Of T) (ptr As IntPtr) As T

Parámetros de tipo

T

Tipo del objeto al que se van a copiar los datos. Debe ser una clase con formato o una estructura.

Parámetros

ptr
IntPtr

nativeint

Puntero a un bloque de memoria no administrado.

Devoluciones

T

Objeto administrado que contiene los datos a los que apunta el ptr parámetro.

Atributos

Excepciones

El diseño de T no es secuencial o explícito.

La clase especificada por T no tiene un constructor sin parámetros accesible.

Comentarios

PtrToStructure<T>(IntPtr) a menudo es necesario en la interoperabilidad COM e invocación de plataforma cuando los parámetros de estructura se representan como System.IntPtr valores. Puede pasar un tipo de valor a esta sobrecarga de método. Si el ptr parámetro es igual IntPtr.Zero a y T es un tipo de referencia, null se devuelve. Si ptr es IntPtr.Zero igual a y T es un tipo de valor, se produce una NullReferenceException excepción .

Se aplica a

PtrToStructure<T>(IntPtr, T)

Serializa los datos de un bloque de memoria no administrado a un objeto administrado del tipo especificado.

public:
generic <typename T>
 static void PtrToStructure(IntPtr ptr, T structure);
[System.Security.SecurityCritical]
public static void PtrToStructure<T>(IntPtr ptr, T structure);
public static void PtrToStructure<T>(IntPtr ptr, T structure);
[<System.Security.SecurityCritical>]
static member PtrToStructure : nativeint * 'T -> unit
static member PtrToStructure : nativeint * 'T -> unit
Public Shared Sub PtrToStructure(Of T) (ptr As IntPtr, structure As T)

Parámetros de tipo

T

Tipo de structure. Debe ser una clase con formato.

Parámetros

ptr
IntPtr

nativeint

Puntero a un bloque de memoria no administrado.

structure
T

Objeto al que se van a copiar los datos.

Atributos

Excepciones

El diseño de la estructura no es secuencial ni explícito.

Comentarios

PtrToStructure<T>(IntPtr, T) a menudo es necesario en la interoperabilidad COM e invocación de plataforma cuando los parámetros de estructura se representan como IntPtr valores. No se puede usar esta sobrecarga de método con tipos de valor. Si el ptr parámetro es igual IntPtr.Zero a y T es un tipo de referencia, null se devuelve. Si ptr es IntPtr.Zero igual a y T es un tipo de valor, se produce una NullReferenceException excepción .

Se aplica a