Marshal Methods

Marshal Methods

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

The Marshal type exposes the following members.

  NameDescription
Public method Static member AddRef Security Critical. Increments the reference count on the specified interface.
Public method Static member AllocCoTaskMem Security Critical. Allocates a block of memory of specified size from the COM task memory allocator.
Public method Static member AllocHGlobal Security Critical. Allocates memory from the unmanaged memory of the process by using the specified number of bytes.
Public method Static member Copy(Byte[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed 8-bit unsigned integer array to an unmanaged memory pointer.
Public method Static member Copy(Char[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed character array to an unmanaged memory pointer.
Public method Static member Copy(Double[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed double-precision floating-point number array to an unmanaged memory pointer.
Public method Static member Copy(Int16[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed 16-bit signed integer array to an unmanaged memory pointer.
Public method Static member Copy(Int32[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointer.
Public method Static member Copy(Int64[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed 64-bit signed integer array to an unmanaged memory pointer.
Public method Static member Copy(IntPtr, Byte[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed 8-bit unsigned integer array.
Public method Static member Copy(IntPtr, Char[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed character array.
Public method Static member Copy(IntPtr, Double[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed double-precision floating-point number array.
Public method Static member Copy(IntPtr, Int16[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed 16-bit signed integer array.
Public method Static member Copy(IntPtr, Int32[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed 32-bit signed integer array.
Public method Static member Copy(IntPtr, Int64[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed 64-bit signed integer array.
Public method Static member Copy(IntPtr, Single[], Int32, Int32) Security Critical. Copies data from an unmanaged memory pointer to a managed single-precision floating-point number array.
Public method Static member Copy(Single[], Int32, IntPtr, Int32) Security Critical. Copies data from a one-dimensional, managed single-precision floating-point number array to an unmanaged memory pointer.
Public method Static member FinalReleaseComObject Security Critical. Releases all references to a runtime callable wrapper (RCW) by setting its reference count to 0.
Public method Static member FreeCoTaskMem Security Critical. Frees a block of memory allocated by the unmanaged COM task memory allocator.
Public method Static member FreeHGlobal Security Critical. Frees memory previously allocated from the unmanaged memory of the process.
Public method Static member GetComInterfaceForObject Security Critical. Returns a pointer to an IUnknown interface that represents the specified interface on the specified object. Custom query interface access is enabled by default.
Public method Static member GetDelegateForFunctionPointer Security Critical. Converts an unmanaged function pointer to a delegate.
Public method Static member GetExceptionForHR(Int32) Security Critical. Converts the specified HRESULT error code to a corresponding Exception object.
Public method Static member GetExceptionForHR(Int32, IntPtr) Security Critical. Converts the specified HRESULT error code to a corresponding Exception object, with additional error information passed in an [4dda6909-2d9a-4727-ae0c-b5f90dcfa447] interface for the exception object.
Public method Static member GetFunctionPointerForDelegate Security Critical. Converts a delegate into a function pointer callable from unmanaged code.
Public method Static member GetHRForException Security Critical. Converts the specified exception to an HRESULT.
Public method Static member GetHRForLastWin32Error Security Critical. Returns the HRESULT corresponding to the last error incurred by Win32 code executed using Marshal.
Public method Static member GetIUnknownForObject Security Critical. Returns an IUnknown interface from a managed object.
Public method Static member GetLastWin32Error Security Critical. Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set.
Public method Static member GetNativeVariantForObject Security Critical. Converts an object to a COM VARIANT.
Public method Static member GetObjectForIUnknown Security Critical. Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.
Public method Static member GetObjectForNativeVariant Security Critical. Converts a COM VARIANT to an object.
Public method Static member GetUniqueObjectForIUnknown Security Critical. Creates a unique [7e542583-1e31-4e10-b523-8cf2f29cb4a4] (RCW) object for a given IUnknown interface.
Public method Static member IsComObject Indicates whether a specified object represents a COM object.
Public method Static member Prelink Security Critical. Executes one-time method setup tasks without calling the method.
Public method Static member PrelinkAll Security Critical. Performs a pre-link check for all methods on a class.
Public method Static member PtrToStringAnsi(IntPtr) Security Critical. Copies all characters up to the first null from an unmanaged ANSI string to a managed String. Widens each ANSI character to Unicode.
Public method Static member PtrToStringAnsi(IntPtr, Int32) Security Critical. Allocates a managed String, copies a specified number of characters from an unmanaged ANSI string into it, and widens each ANSI character to Unicode.
Public method Static member PtrToStringUni(IntPtr) Security Critical. Allocates a managed String and copies all characters up to the first null character from an unmanaged Unicode string into it.
Public method Static member PtrToStringUni(IntPtr, Int32) Security Critical. Copies a specified number of characters from a Unicode string stored in native heap to a managed String.
Public method Static member PtrToStructure(IntPtr, Object) Security Critical. Marshals data from an unmanaged block of memory to a managed object.
Public method Static member PtrToStructure(IntPtr, Type) Security Critical. Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified type.
Public method Static member QueryInterface Security Critical. Requests a pointer to a specified interface from a COM object.
Public method Static member ReadByte(IntPtr) Security Critical. Reads a single byte from an unmanaged pointer.
Public method Static member ReadByte(IntPtr, Int32) Security Critical. Reads a single byte at a given offset (or index) from an unmanaged pointer.
Public method Static member ReadInt16(IntPtr) Security Critical. Reads a 16-bit signed integer from the unmanaged memory.
Public method Static member ReadInt16(IntPtr, Int32) Security Critical. Reads a 16-bit signed integer from unmanaged memory.
Public method Static member ReadInt32(IntPtr) Security Critical. Reads a 32-bit signed integer from unmanaged memory.
Public method Static member ReadInt32(IntPtr, Int32) Security Critical. Reads a 32-bit signed integer from unmanaged memory.
Public method Static member ReadInt64(IntPtr) Security Critical. Reads a 64-bit signed integer from unmanaged memory.
Public method Static member ReadInt64(IntPtr, Int32) Security Critical. Reads a 64-bit signed integer from unmanaged memory.
Public method Static member ReadIntPtr(IntPtr) Security Critical. Reads a processor native sized integer from unmanaged memory.
Public method Static member ReadIntPtr(IntPtr, Int32) Security Critical. Reads a processor native sized integer from unmanaged memory.
Public method Static member Release Security Critical. Decrements the reference count on the specified interface.
Public method Static member ReleaseComObject Security Critical. Decrements the reference count of the specified [7e542583-1e31-4e10-b523-8cf2f29cb4a4] (RCW) associated with the specified COM object.
Public method Static member SizeOf(Object) Returns the unmanaged size of an object in bytes.
Public method Static member SizeOf(Type) Returns the size of an unmanaged type in bytes.
Public method Static member StructureToPtr Security Critical. Marshals data from a managed object to an unmanaged block of memory.
Public method Static member ThrowExceptionForHR(Int32) Security Critical. Throws an exception with a specific failure HRESULT value.
Public method Static member ThrowExceptionForHR(Int32, IntPtr) Security Critical. Throws an exception with a specific failure HRESULT.
Public method Static member UnsafeAddrOfPinnedArrayElement Security Critical. Gets the address of the element at the specified index inside the specified array.
Public method Static member WriteByte(IntPtr, Byte) Security Critical. Writes a single byte value to unmanaged memory.
Public method Static member WriteByte(IntPtr, Int32, Byte) Security Critical. Writes a single byte value to unmanaged memory.
Public method Static member WriteInt16(IntPtr, Int16) Security Critical. Writes a 16-bit integer value to unmanaged memory.
Public method Static member WriteInt16(IntPtr, Int32, Int16) Security Critical. Writes a 16-bit signed integer value into unmanaged memory.
Public method Static member WriteInt32(IntPtr, Int32) Security Critical. Writes a 32-bit signed integer value to unmanaged memory.
Public method Static member WriteInt32(IntPtr, Int32, Int32) Security Critical. Writes a 32-bit signed integer value into unmanaged memory.
Public method Static member WriteInt64(IntPtr, Int64) Security Critical. Writes a 64-bit signed integer value to unmanaged memory.
Public method Static member WriteInt64(IntPtr, Int32, Int64) Security Critical. Writes a 64-bit signed integer value to unmanaged memory.
Public method Static member WriteIntPtr Security Critical. Writes a processor native sized integer value into unmanaged memory.
Top

Show:
© 2017 Microsoft