Export (0) Print
Expand All

Marshal Members

Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.

The Marshal type exposes the following members.

  NameDescription
Public method Static member Supported by the .NET Compact Framework AddRef Increments the reference count on the specified interface.
Public method Static member Supported by the .NET Compact Framework AllocCoTaskMem Allocates a block of memory of specified size from the COM task memory allocator.
Public method Static member Supported by the .NET Compact Framework AllocHGlobal Overloaded. Allocates a block of memory using LocalAlloc.
Public method Static member BindToMoniker Gets an interface pointer identified by the specified moniker.
Public method Static member ChangeWrapperHandleStrength Changes the strength of a COM callable wrapper's (CCW) handle on the object it contains.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Copy Overloaded. Copies data from a managed array to an unmanaged memory pointer, or from an unmanaged memory pointer to a managed array.
Public method Static member CreateAggregatedObject Aggregates a managed object with the specified COM object.
Public method Static member CreateWrapperOfType Wraps the specified COM object in an object of the specified type.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework DestroyStructure Frees all substructures pointed to by the specified unmanaged memory block.
Public method Static member Supported by the .NET Compact Framework FinalReleaseComObject Releases all references to a runtime callable wrapper (RCW) by setting the reference count of the supplied RCW to 0.
Public method Static member Supported by the .NET Compact Framework FreeBSTR Frees a BSTR using SysFreeString.
Public method Static member Supported by the .NET Compact Framework FreeCoTaskMem Frees a block of memory allocated by the unmanaged COM task memory allocator with Marshal.AllocCoTaskMem.
Public method Static member Supported by the .NET Compact Framework FreeHGlobal Frees memory previously allocated from the unmanaged memory of the process with AllocHGlobal.
Public method Static member 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 method Static member GenerateProgIdForType Returns a programmatic identifier (ProgID) for the specified type.
Public method Static member GetActiveObject Obtains a running instance of the specified object from the Running Object Table (ROT).
Public method Static member Supported by the .NET Compact Framework GetComInterfaceForObject Returns an interface pointer that represents the specified interface for an object.
Public method Static member GetComInterfaceForObjectInContext Returns an interface pointer that represents the specified interface for an object, if the caller is in the same context as that object.
Public method Static member GetComObjectData Gets data referenced by the specified key from the specified COM object.
Public method Static member GetComSlotForMethodInfo Gets the virtual function table (VTBL) slot for a specified System.Reflection.MemberInfo when exposed to COM.
Public method Static member GetDelegateForFunctionPointer Converts an unmanaged function pointer to a delegate.
Public method Static member GetEndComSlot Gets the last slot in the virtual function table (VTBL) of a type when exposed to COM.
Public method Static member GetExceptionCode Retrieves a code that identifies the type of the exception that occurred.
Public method Static member Supported by the .NET Compact Framework GetExceptionForHR Overloaded. Converts an HRESULT error code to a corresponding Exception object.
Public method Static member GetExceptionPointers Retrieves a computer-independent description of an exception, and information about the state that existed for the thread when the exception occurred.
Public method Static member Supported by the .NET Compact Framework GetFunctionPointerForDelegate Converts a delegate into a function pointer callable from unmanaged code.
Public method Static member GetHINSTANCE Returns the instance handle (HINSTANCE) for the specified module.
Public method Static member Supported by the .NET Compact Framework GetHRForException Converts the specified exception to an HRESULT.
Public method Static member GetHRForLastWin32Error Returns the HRESULT corresponding to the last error incurred by Win32 code executed using Marshal.
Public method Static member Supported by the .NET Compact Framework GetIDispatchForObject Returns an IDispatch interface from a managed object.
Public method Static member GetIDispatchForObjectInContext Returns an IDispatch interface pointer from a managed object, if the caller is in the same context as that object.
Public method Static member GetITypeInfoForType Returns an ITypeInfo interface from a managed type.
Public method Static member Supported by the .NET Compact Framework GetIUnknownForObject Returns an IUnknown interface from a managed object.
Public method Static member GetIUnknownForObjectInContext Returns an IUnknown interface from a managed object, if the caller is in the same context as that object.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework GetLastWin32Error 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 GetManagedThunkForUnmanagedMethodPtr Obsolete. Gets a pointer to a thunk that marshals a call from managed to unmanaged code.
Public method Static member GetMethodInfoForComSlot Retrieves MethodInfo for the specified virtual function table (VTBL) slot.
Public method Static member Supported by the .NET Compact Framework GetNativeVariantForObject Converts an object to a COM VARIANT.
Public method Static member Supported by the .NET Compact Framework GetObjectForIUnknown Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.
Public method Static member Supported by the .NET Compact Framework GetObjectForNativeVariant Converts a COM VARIANT to an object.
Public method Static member GetObjectsForNativeVariants Converts an array of COM VARIANTs to an array of objects.
Public method Static member GetStartComSlot Gets the first slot in the virtual function table (VTBL) that contains user defined methods.
Public method Static member GetThreadFromFiberCookie Obsolete. Converts a fiber cookie into the corresponding System.Threading.Thread instance.
Public method Static member Supported by the .NET Compact Framework GetTypedObjectForIUnknown Returns a managed object of a specified type that represents a COM object.
Public method Static member GetTypeForITypeInfo Converts an ITypeInfo into a managed Type object.
Public method Static member GetTypeInfoName Overloaded. Retrieves the name of the type represented by an ITypeInfo.
Public method Static member GetTypeLibGuid Overloaded. Retrieves the library identifier (LIBID) of a type library.
Public method Static member GetTypeLibGuidForAssembly Retrieves the library identifier (LIBID) that is assigned to a type library when it was exported from the specified assembly.
Public method Static member GetTypeLibLcid Overloaded. Retrieves the LCID of a type library.
Public method Static member GetTypeLibName Overloaded. Retrieves the name of a type library.
Public method Static member GetTypeLibVersionForAssembly Retrieves the version number of a type library that will be exported from the specified assembly.
Public method Static member GetUniqueObjectForIUnknown Creates a unique runtime callable wrapper (RCW) object for a given IUnknown.
Public method Static member GetUnmanagedThunkForManagedMethodPtr Obsolete. Gets a pointer to a thunk that marshals a call from unmanaged to managed code.
Public method Static member Supported by the .NET Compact Framework IsComObject Indicates whether a specified object represents a COM object.
Public method Static member Supported by the .NET Compact Framework IsTypeVisibleFromCom Indicates whether a type is visible to COM clients.
Public method Static member NumParamBytes Calculates the number of bytes in unmanaged memory that are required to hold the parameters for the specified method.
Public method Static member OffsetOf Returns the field offset of the unmanaged form of the managed class.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework Prelink Executes one-time method setup tasks without calling the method.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework PrelinkAll Performs a pre-link check for all methods on a class.
Public method Static member PtrToStringAnsi Overloaded. Allocates a managed String and copies all or part of an unmanaged ANSI string into it.
Public method Static member PtrToStringAuto Overloaded. Allocates a managed String and copies a specified number of characters from an unmanaged string into it.
Public method Static member Supported by the .NET Compact Framework PtrToStringBSTR Allocates a managed String and copies a BSTR string stored in unmanaged memory into it.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework PtrToStringUni Overloaded. Allocates a managed String and copies a specified number of characters from an unmanaged Unicode string into it.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework PtrToStructure Overloaded. Marshals data from an unmanaged block of memory to a managed object.
Public method Static member Supported by the .NET Compact Framework QueryInterface Requests a pointer to a specified interface from a COM object.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework ReadByte Overloaded. Reads a single byte from an unmanaged pointer. Reading from unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework ReadInt16 Overloaded. Reads a 16-bit signed integer from unmanaged memory. Reading from unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework ReadInt32 Overloaded. Reads a 32-bit signed integer from unmanaged memory. Reading from unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework ReadInt64 Overloaded. Reads a 64-bit signed integer from unmanaged memory. Reading from unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework ReadIntPtr Overloaded. Reads a processor native sized integer from unmanaged memory. Reading from unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework ReAllocCoTaskMem Resizes a block of memory previously allocated with AllocCoTaskMem.
Public method Static member Supported by the .NET Compact Framework ReAllocHGlobal Resizes a block of memory previously allocated with AllocHGlobal.
Public method Static member Supported by the .NET Compact Framework Release Decrements the reference count on the specified interface.
Public method Static member Supported by the .NET Compact Framework ReleaseComObject Decrements the reference count of the supplied runtime callable wrapper.
Public method Static member ReleaseThreadCache Obsolete. Releases the thread cache.
Public method Static member SecureStringToBSTR Allocates a BSTR and copies the contents of a managed SecureString object into it.
Public method Static member SecureStringToCoTaskMemAnsi Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.
Public method Static member SecureStringToCoTaskMemUnicode Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.
Public method Static member SecureStringToGlobalAllocAnsi Copies the contents of a managed SecureString into unmanaged memory, converting into ANSI format as it copies.
Public method Static member SecureStringToGlobalAllocUnicode Copies the contents of a managed SecureString object into unmanaged memory.
Public method Static member SetComObjectData Sets data referenced by the specified key in the specified COM object.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework SizeOf Overloaded. Returns the unmanaged size, in bytes, of a class using Marshal.
Public method Static member Supported by the .NET Compact Framework StringToBSTR Allocates a BSTR and copies the contents of a managed String into it.
Public method Static member StringToCoTaskMemAnsi Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.
Public method Static member StringToCoTaskMemAuto Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.
Public method Static member StringToCoTaskMemUni Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.
Public method Static member StringToHGlobalAnsi Copies the contents of a managed String into unmanaged memory, converting into ANSI format as it copies.
Public method Static member StringToHGlobalAuto Copies the contents of a managed String into unmanaged memory, converting into ANSI format if required.
Public method Static member StringToHGlobalUni Copies the contents of a managed String into unmanaged memory.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework StructureToPtr Marshals data from a managed object to an unmanaged block of memory.
Public method Static member Supported by the .NET Compact Framework ThrowExceptionForHR Overloaded. Throws an exception with a specific failure HRESULT value.
Public method Static member UnsafeAddrOfPinnedArrayElement Gets the address of the element at the specified index inside the specified array.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework WriteByte Overloaded. Writes a single byte value to unmanaged memory.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework WriteInt16 Overloaded. Writes a 16-bit signed integer value to unmanaged memory. Writing to unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework WriteInt32 Overloaded. Writes a 32-bit signed integer value to unmanaged memory. Writing to unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework WriteInt64 Overloaded. Writes a 64-bit signed integer value to unmanaged memory. Writing to unaligned memory locations is supported.
Public method Static member Supported by the .NET Compact Framework Supported by the XNA Framework WriteIntPtr Overloaded. Writes a processor native sized integer value to unmanaged memory. Writing to unaligned memory locations is supported.
Public method Static member ZeroFreeBSTR Frees a BSTR pointer that was allocated using the SecureStringToBSTR method.
Public method Static member ZeroFreeCoTaskMemAnsi Frees an unmanaged string pointer that was allocated using the SecureStringToCoTaskMemAnsi method.
Public method Static member ZeroFreeCoTaskMemUnicode Frees an unmanaged string pointer that was allocated using the SecureStringToCoTaskMemUnicode method.
Public method Static member ZeroFreeGlobalAllocAnsi Frees an unmanaged string pointer that was allocated using the SecureStringToGlobalAllocAnsi method.
Public method Static member ZeroFreeGlobalAllocUnicode Frees an unmanaged string pointer that was allocated using the SecureStringToGlobalAllocUnicode method.
Top

  NameDescription
Public field Static member Supported by the .NET Compact Framework Supported by the XNA Framework SystemDefaultCharSize Represents the default character size on the system; the default is 2 for Unicode systems and 1 for ANSI systems. This field is read-only.
Public field Static member SystemMaxDBCSCharSize Represents the maximum size of a double byte character set (DBCS) size, in bytes, for the current operating system. This field is read-only.
Top

Community Additions

ADD
Show:
© 2014 Microsoft