Export (0) Print
Expand All
Expand Minimize

Marshal Methods

The methods of the Marshal class are listed here. For a complete list of Marshal class members, see the Marshal Members topic.

Public Methods

public methodstatic (Shared in Visual Basic)AddRef Increments the reference count on the specified interface.
public methodstatic (Shared in Visual Basic)AllocCoTaskMem Allocates a block of memory of specified size from the COM task memory allocator.
public methodstatic (Shared in Visual Basic)AllocHGlobal Overloaded. Allocates a block of memory using GlobalAlloc.
public methodstatic (Shared in Visual Basic)BindToMoniker Gets an interface pointer identified by the specified moniker.
public methodstatic (Shared in Visual Basic)ChangeWrapperHandleStrength Changes the strength of a COM callable wrapper's (CCW) handle on the object it contains.
public methodstatic (Shared in Visual Basic)Copy

Supported by the .NET Compact Framework.

Overloaded. Copies data from a managed array to an unmanaged memory pointer.
public methodstatic (Shared in Visual Basic)CreateWrapperOfType Wraps the specified COM object in an object of the specified type.
public methodstatic (Shared in Visual Basic)DestroyStructure Frees all substructures pointed to by the specified unmanaged memory block.
public methodstatic (Shared in Visual Basic)FreeBSTR Frees a BSTR using SysFreeString.
public methodstatic (Shared in Visual Basic)FreeCoTaskMem Frees a block of memory allocated by the unmanaged COM task memory allocator with Marshal.AllocCoTaskMem.
public methodstatic (Shared in Visual Basic)FreeHGlobal Frees memory previously allocated from the unmanaged memory of the process with AllocHGlobal.
public methodstatic (Shared in Visual Basic)GenerateGuidForType Returns the globally unique identifier (GUID) for the specified type, or generates a GUID using the algorithm used by the Type Library Exporter (Tlbexp.exe).
public methodstatic (Shared in Visual Basic)GenerateProgIdForType Returns a programmatic identifier (ProgID) for the specified type.
public methodstatic (Shared in Visual Basic)GetActiveObject Obtains a running instance of the specified object from the Running Object Table (ROT).
public methodstatic (Shared in Visual Basic)GetComInterfaceForObject Returns an IUnknown pointer representing the specified interface for an object.
public methodstatic (Shared in Visual Basic)GetComObjectData Gets data referenced by the specified key from the specified COM object.
public methodstatic (Shared in Visual Basic)GetComSlotForMethodInfo Gets the virtual function table (VTBL) slot for a specified System.Reflection.MemberInfo when exposed to COM.
public methodstatic (Shared in Visual Basic)GetEndComSlot Gets the last slot in the virtual function table (VTBL) of a type when exposed to COM.
public methodstatic (Shared in Visual Basic)GetExceptionCode Retrieves a code that identifies the type of the exception that occurred.
public methodstatic (Shared in Visual Basic)GetExceptionPointers Retrieves a computer-independent description of an exception, and information about the state that existed for the thread when the exception occurred.
public methodstatic (Shared in Visual Basic)GetHINSTANCE Returns the instance handle (HINSTANCE) for the specified module.
public methodstatic (Shared in Visual Basic)GetHRForException Converts the specified exception to an HRESULT.
public methodstatic (Shared in Visual Basic)GetHRForLastWin32Error Returns the HRESULT corresponding to the last error incurred by Win32 code executed using Marshal.
public methodstatic (Shared in Visual Basic)GetIDispatchForObject Returns an IDispatch interface from a managed object.
public methodstatic (Shared in Visual Basic)GetITypeInfoForType Returns an ITypeInfo interface from a managed type.
public methodstatic (Shared in Visual Basic)GetIUnknownForObject Returns an IUnknown interface from a managed object.
public methodstatic (Shared in Visual Basic)GetLastWin32Error

Supported by the .NET Compact Framework.

Returns the error code returned by the last unmanaged function called using platform invoke that has the DllImportAttribute.SetLastError flag set.
public methodstatic (Shared in Visual Basic)GetManagedThunkForUnmanagedMethodPtr Gets a pointer to a thunk that marshals a call from managed to unmanaged code.
public methodstatic (Shared in Visual Basic)GetMethodInfoForComSlot Retrieves MethodInfo for the specified virtual function table (VTBL) slot.
public methodstatic (Shared in Visual Basic)GetNativeVariantForObject Converts an object to a COM VARIANT.
public methodstatic (Shared in Visual Basic)GetObjectForIUnknown Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.
public methodstatic (Shared in Visual Basic)GetObjectForNativeVariant Converts a COM VARIANT to an object.
public methodstatic (Shared in Visual Basic)GetObjectsForNativeVariants Converts an array of COM VARIANTs to an array of objects.
public methodstatic (Shared in Visual Basic)GetStartComSlot Gets the first slot in the virtual function table (VTBL) that contains user defined methods.
public methodstatic (Shared in Visual Basic)GetThreadFromFiberCookie Converts a fiber cookie into the corresponding System.Threading.Thread instance.
public methodstatic (Shared in Visual Basic)GetTypedObjectForIUnknown Returns a managed object of a specified type that represents a COM object.
public methodstatic (Shared in Visual Basic)GetTypeForITypeInfo Converts an ITypeInfo into a managed Type object.
public methodstatic (Shared in Visual Basic)GetTypeInfoName Retrieves the name of the type represented by an ITypeInfo.
public methodstatic (Shared in Visual Basic)GetTypeLibGuid Retrieves the library identifier (LIBID) of a type library.
public methodstatic (Shared in Visual Basic)GetTypeLibGuidForAssembly Retrieves the library identifier (LIBID) that is assigned to a type library when it was exported from the specified assembly.
public methodstatic (Shared in Visual Basic)GetTypeLibLcid Retrieves the LCID of a type library.
public methodstatic (Shared in Visual Basic)GetTypeLibName Retrieves the name of a type library.
public methodstatic (Shared in Visual Basic)GetUnmanagedThunkForManagedMethodPtr Gets a pointer to a thunk that marshals a call from unmanaged to managed code.
public methodstatic (Shared in Visual Basic)IsComObject

Supported by the .NET Compact Framework.

Indicates whether a specified object represents a COM object.
public methodstatic (Shared in Visual Basic)IsTypeVisibleFromCom Indicates whether a type is visible to COM clients.
public methodstatic (Shared in Visual Basic)NumParamBytes Calculates the number of bytes required to hold the parameters for the specified method.
public methodstatic (Shared in Visual Basic)OffsetOf Returns the field offset of the unmanaged form of the managed class.
public methodstatic (Shared in Visual Basic)Prelink Executes one-time method setup tasks without calling the method.
public methodstatic (Shared in Visual Basic)PrelinkAll Performs a pre-link check for all methods on a class.
public methodstatic (Shared in Visual Basic)PtrToStringAnsi Overloaded. Allocates a managed String and copies all or part of an unmanaged ANSI string into it.
public methodstatic (Shared in Visual Basic)PtrToStringAuto Overloaded. Allocates a managed String and copies a specified number of characters from an unmanaged string into it.
public methodstatic (Shared in Visual Basic)PtrToStringBSTR Allocates a managed String and copies a BSTR string stored in unmanaged memory into it.
public methodstatic (Shared in Visual Basic)PtrToStringUni

Supported by the .NET Compact Framework.

Overloaded. Allocates a managed String and copies a specified number of characters from an unmanaged Unicode string into it.
public methodstatic (Shared in Visual Basic)PtrToStructure

Supported by the .NET Compact Framework.

Overloaded. Marshals data from an unmanaged block of memory to a managed object.
public methodstatic (Shared in Visual Basic)QueryInterface Requests a pointer to a specified interface from a COM object.
public methodstatic (Shared in Visual Basic)ReadByte

Supported by the .NET Compact Framework.

Overloaded. Reads a single byte from an unmanaged pointer.
public methodstatic (Shared in Visual Basic)ReadInt16

Supported by the .NET Compact Framework.

Overloaded. Reads a 16-bit signed integer from unmanaged memory.
public methodstatic (Shared in Visual Basic)ReadInt32

Supported by the .NET Compact Framework.

Overloaded. Reads a 32-bit signed integer from unmanaged memory.
public methodstatic (Shared in Visual Basic)ReadInt64 Overloaded. Reads a 64-bit signed integer from unmanaged memory.
public methodstatic (Shared in Visual Basic)ReadIntPtr Overloaded. Reads a processor native sized integer from unmanaged memory.
public methodstatic (Shared in Visual Basic)ReAllocCoTaskMem Resizes a block of memory previously allocated with AllocCoTaskMem.
public methodstatic (Shared in Visual Basic)ReAllocHGlobal Resizes a block of memory previously allocated with AllocHGlobal.
public methodstatic (Shared in Visual Basic)Release Decrements the reference count on the specified interface.
public methodstatic (Shared in Visual Basic)ReleaseComObject Decrements the reference count of the supplied runtime callable wrapper.
public methodstatic (Shared in Visual Basic)ReleaseThreadCache This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
public methodstatic (Shared in Visual Basic)SetComObjectData Sets data referenced by the specified key in the specified COM object.
public methodstatic (Shared in Visual Basic)SizeOf

Supported by the .NET Compact Framework.

Overloaded. Returns the unmanaged size, in bytes, of a class using Marshal.
public methodstatic (Shared in Visual Basic)StringToBSTR Allocates a BSTR and copies the contents of a managed String into it.
public methodstatic (Shared in Visual Basic)StringToCoTaskMemAnsi Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.
public methodstatic (Shared in Visual Basic)StringToCoTaskMemAuto Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.
public methodstatic (Shared in Visual Basic)StringToCoTaskMemUni Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.
public methodstatic (Shared in Visual Basic)StringToHGlobalAnsi Copies the contents of a managed String into unmanaged memory, converting into ANSI format as it copies.
public methodstatic (Shared in Visual Basic)StringToHGlobalAuto Copies the contents of a managed String into unmanaged memory, converting into ANSI format if required.
public methodstatic (Shared in Visual Basic)StringToHGlobalUni Copies the contents of a managed String into unmanaged memory.
public methodstatic (Shared in Visual Basic)StructureToPtr

Supported by the .NET Compact Framework.

Marshals data from a managed object to an unmanaged block of memory.
public methodstatic (Shared in Visual Basic)ThrowExceptionForHR Overloaded. Throws an exception with a specific failure HRESULT value.
public methodstatic (Shared in Visual Basic)UnsafeAddrOfPinnedArrayElement Gets the address of the element at the specified index inside the specified array.
public methodstatic (Shared in Visual Basic)WriteByte

Supported by the .NET Compact Framework.

Overloaded. Writes a single byte value to unmanaged memory.
public methodstatic (Shared in Visual Basic)WriteInt16

Supported by the .NET Compact Framework.

Overloaded. Writes a 16-bit signed integer value to unmanaged memory.
public methodstatic (Shared in Visual Basic)WriteInt32

Supported by the .NET Compact Framework.

Overloaded. Writes a 32-bit signed integer value to unmanaged memory.
public methodstatic (Shared in Visual Basic)WriteInt64 Overloaded. Writes a 64-bit signed integer value to unmanaged memory.
public methodstatic (Shared in Visual Basic)WriteIntPtr Overloaded. Writes a processor native sized integer value to unmanaged memory.

See Also

Marshal Class | System.Runtime.InteropServices Namespace

Show:
© 2014 Microsoft