Marshal.PtrToStructure Method (IntPtr, Type)
Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified type.
Assembly: mscorlib (in mscorlib.dll)
[<ComVisibleAttribute(true)>] static member PtrToStructure : ptr:IntPtr * structureType:Type -> Object
- Type: System.IntPtr
A pointer to an unmanaged block of memory.
- Type: System.Type
The type of object to be created. This object must represent a formatted class or a structure.
Return ValueType: System.Object
A managed object containing the data pointed to by the ptr parameter.
The following example creates a managed structure, transfers it to unmanaged memory, and then transfers it back to managed memory using the PtrToStructure method.
The following example demonstrates how to marshal an unmanaged block of memory to a managed structure using the PtrToStructure method.
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.