Muokkaa

Jaa


Marshal Class

Definition

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.

public ref class Marshal abstract sealed
public ref class Marshal sealed
public static class Marshal
public sealed class Marshal
type Marshal = class
Public Class Marshal
Public NotInheritable Class Marshal
Inheritance
Marshal

Examples

The following example shows how to use various methods defined by the Marshal class.

using namespace System;
using namespace System::Runtime::InteropServices;

public value struct Point
{
public:
    property int X;
    property int Y;
};
extern bool CloseHandle(IntPtr h);

int main()
{
    // Demonstrate the use of public static fields of the Marshal
    // class.
    Console::WriteLine(
        "SystemDefaultCharSize={0},SystemMaxDBCSCharSize={1}",
        Marshal::SystemDefaultCharSize,
        Marshal::SystemMaxDBCSCharSize);

    // Demonstrate the use of the SizeOf method of the Marshal
    // class.
    Console::WriteLine("Number of bytes needed by a Point object: {0}",
        Marshal::SizeOf(Point::typeid));
    Point point;
    Console::WriteLine("Number of bytes needed by a Point object: {0}",
        Marshal::SizeOf(point));

    // Demonstrate how to call GlobalAlloc and 
    // GlobalFree using the Marshal class.
    IntPtr hglobal = Marshal::AllocHGlobal(100);
    Marshal::FreeHGlobal(hglobal);

    // Demonstrate how to use the Marshal class to get the Win32
    // error code when a Win32 method fails.
    bool isCloseHandleSuccess = CloseHandle(IntPtr(-1));
    if (!isCloseHandleSuccess)
    {
        Console::WriteLine(
            "CloseHandle call failed with an error code of: {0}",
            Marshal::GetLastWin32Error());
    }
};

// This is a platform invoke prototype. SetLastError is true,
// which allows the GetLastWin32Error method of the Marshal class
// to work correctly.    
[DllImport("Kernel32", ExactSpelling = true, SetLastError = true)]
extern bool CloseHandle(IntPtr h);

// This code produces the following output.
// 
// SystemDefaultCharSize=2, SystemMaxDBCSCharSize=1
// Number of bytes needed by a Point object: 8
// Number of bytes needed by a Point object: 8
// CloseHandle call failed with an error code of: 6
using System;
using System.Text;
using System.Runtime.InteropServices;

public struct Point
{
    public Int32 x, y;
}

public sealed class App
{
    static void Main()
    {
        // Demonstrate the use of public static fields of the Marshal class.
        Console.WriteLine("SystemDefaultCharSize={0}, SystemMaxDBCSCharSize={1}",
            Marshal.SystemDefaultCharSize, Marshal.SystemMaxDBCSCharSize);

        // Demonstrate the use of the SizeOf method of the Marshal class.
        Console.WriteLine("Number of bytes needed by a Point object: {0}",
            Marshal.SizeOf(typeof(Point)));
        Point p = new Point();
        Console.WriteLine("Number of bytes needed by a Point object: {0}",
            Marshal.SizeOf(p));

        // Demonstrate how to call GlobalAlloc and
        // GlobalFree using the Marshal class.
        IntPtr hglobal = Marshal.AllocHGlobal(100);
        Marshal.FreeHGlobal(hglobal);

        // Demonstrate how to use the Marshal class to get the Win32 error
        // code when a Win32 method fails.
        Boolean f = CloseHandle(new IntPtr(-1));
        if (!f)
        {
            Console.WriteLine("CloseHandle call failed with an error code of: {0}",
                Marshal.GetLastWin32Error());
        }
    }

    // This is a platform invoke prototype. SetLastError is true, which allows
    // the GetLastWin32Error method of the Marshal class to work correctly.
    [DllImport("Kernel32", ExactSpelling = true, SetLastError = true)]
    static extern Boolean CloseHandle(IntPtr h);
}

// This code produces the following output.
//
// SystemDefaultCharSize=2, SystemMaxDBCSCharSize=1
// Number of bytes needed by a Point object: 8
// Number of bytes needed by a Point object: 8
// CloseHandle call failed with an error code of: 6
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Security.Permissions



Public Structure Point
    Public x, y As Int32
End Structure



Public NotInheritable Class App

    <SecurityPermission(SecurityAction.LinkDemand, Unrestricted:=True)> _
    Shared Sub Main()
        ' Demonstrate the use of public static fields of the Marshal class.
        Console.WriteLine("SystemDefaultCharSize={0}, SystemMaxDBCSCharSize={1}", Marshal.SystemDefaultCharSize, Marshal.SystemMaxDBCSCharSize)
        ' Demonstrate the use of the SizeOf method of the Marshal class.
        Console.WriteLine("Number of bytes needed by a Point object: {0}", Marshal.SizeOf(GetType(Point)))
        Dim p As New Point()
        Console.WriteLine("Number of bytes needed by a Point object: {0}", Marshal.SizeOf(p))
        ' Demonstrate how to call GlobalAlloc and 
        ' GlobalFree using the Marshal class.
        Dim hglobal As IntPtr = Marshal.AllocHGlobal(100)
        Marshal.FreeHGlobal(hglobal)
        ' Demonstrate how to use the Marshal class to get the Win32 error 
        ' code when a Win32 method fails.
        Dim f As [Boolean] = CloseHandle(New IntPtr(-1))
        If Not f Then
            Console.WriteLine("CloseHandle call failed with an error code of: {0}", Marshal.GetLastWin32Error())
        End If

    End Sub


    ' This is a platform invoke prototype. SetLastError is true, which allows 
    ' the GetLastWin32Error method of the Marshal class to work correctly.    
    <DllImport("Kernel32", ExactSpelling:=True, SetLastError:=True)> _
    Shared Function CloseHandle(ByVal h As IntPtr) As [Boolean]

    End Function
End Class


' This code produces the following output.
' 
' SystemDefaultCharSize=2, SystemMaxDBCSCharSize=1
' Number of bytes needed by a Point object: 8
' Number of bytes needed by a Point object: 8
' CloseHandle call failed with an error code of: 6

Remarks

The static methods defined on the Marshal class are essential to working with unmanaged code. Most methods defined in this class are typically used by developers who want to provide a bridge between the managed and unmanaged programming models. For example, the StringToHGlobalAnsi method copies ANSI characters from a specified string (in the managed heap) to a buffer in the unmanaged heap. It also allocates the target heap of the right size.

The common language runtime provides specific marshaling capabilities. For details on marshaling behavior, see Interop Marshaling.

The Read and Write methods in the Marshal class support both aligned and unaligned access.

Fields

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.

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.

Methods

AddRef(IntPtr)

Increments the reference count on the specified interface.

AllocCoTaskMem(Int32)

Allocates a block of memory of specified size from the COM task memory allocator.

AllocHGlobal(Int32)

Allocates memory from the unmanaged memory of the process by using the specified number of bytes.

AllocHGlobal(IntPtr)

Allocates memory from the unmanaged memory of the process by using the pointer to the specified number of bytes.

AreComObjectsAvailableForCleanup()

Indicates whether runtime callable wrappers (RCWs) from any context are available for cleanup.

BindToMoniker(String)

Gets an interface pointer identified by the specified moniker.

ChangeWrapperHandleStrength(Object, Boolean)

Changes the strength of an object's COM Callable Wrapper (CCW) handle.

CleanupUnusedObjectsInCurrentContext()

Notifies the runtime to clean up all Runtime Callable Wrappers (RCWs) allocated in the current context.

Copy(Byte[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed 8-bit unsigned integer array to an unmanaged memory pointer.

Copy(Char[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed character array to an unmanaged memory pointer.

Copy(Double[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed double-precision floating-point number array to an unmanaged memory pointer.

Copy(Int16[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed 16-bit signed integer array to an unmanaged memory pointer.

Copy(Int32[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointer.

Copy(Int64[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed 64-bit signed integer array to an unmanaged memory pointer.

Copy(IntPtr, Byte[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed 8-bit unsigned integer array.

Copy(IntPtr, Char[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed character array.

Copy(IntPtr, Double[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed double-precision floating-point number array.

Copy(IntPtr, Int16[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed 16-bit signed integer array.

Copy(IntPtr, Int32[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed 32-bit signed integer array.

Copy(IntPtr, Int64[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed 64-bit signed integer array.

Copy(IntPtr, IntPtr[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed IntPtr array.

Copy(IntPtr, Single[], Int32, Int32)

Copies data from an unmanaged memory pointer to a managed single-precision floating-point number array.

Copy(IntPtr[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed IntPtr array to an unmanaged memory pointer.

Copy(Single[], Int32, IntPtr, Int32)

Copies data from a one-dimensional, managed single-precision floating-point number array to an unmanaged memory pointer.

CreateAggregatedObject(IntPtr, Object)
Obsolete.

Aggregates a managed object with the specified COM object.

CreateAggregatedObject<T>(IntPtr, T)

Aggregates a managed object of the specified type with the specified COM object.

CreateWrapperOfType(Object, Type)
Obsolete.

Wraps the specified COM object in an object of the specified type.

CreateWrapperOfType<T,TWrapper>(T)

Wraps the specified COM object in an object of the specified type.

DestroyStructure(IntPtr, Type)
Obsolete.

Frees all substructures that the specified unmanaged memory block points to.

DestroyStructure<T>(IntPtr)

Frees all substructures of a specified type that the specified unmanaged memory block points to.

FinalReleaseComObject(Object)

Releases all references to a Runtime Callable Wrapper (RCW) by setting its reference count to 0.

FreeBSTR(IntPtr)

Frees a BSTR using the COM SysFreeString function.

FreeCoTaskMem(IntPtr)

Frees a block of memory allocated by the unmanaged COM task memory allocator.

FreeHGlobal(IntPtr)

Frees memory previously allocated from the unmanaged memory of the process.

GenerateGuidForType(Type)

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).

GenerateProgIdForType(Type)

Returns a programmatic identifier (ProgID) for the specified type.

GetActiveObject(String)

Obtains a running instance of the specified object from the running object table (ROT).

GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode)
Obsolete.

Returns a pointer to an IUnknown interface that represents the specified interface on the specified object. Custom query interface access is controlled by the specified customization mode.

GetComInterfaceForObject(Object, Type)
Obsolete.

Returns a pointer to an IUnknown interface that represents the specified interface on the specified object. Custom query interface access is enabled by default.

GetComInterfaceForObject<T,TInterface>(T)

Returns a pointer to an IUnknown interface that represents the specified interface on an object of the specified type. Custom query interface access is enabled by default.

GetComInterfaceForObjectInContext(Object, Type)

Returns an interface pointer that represents the specified interface for an object, if the caller is in the same context as that object.

GetComObjectData(Object, Object)

Retrieves data that is referenced by the specified key from the specified COM object.

GetComSlotForMethodInfo(MemberInfo)

Retrieves the virtual function table (v-table or VTBL) slot for a specified MemberInfo type when that type is exposed to COM.

GetDelegateForFunctionPointer(IntPtr, Type)
Obsolete.

Converts an unmanaged function pointer to a delegate.

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

Converts an unmanaged function pointer to a delegate of a specified type.

GetEndComSlot(Type)

Retrieves the last slot in the virtual function table (v-table or VTBL) of a type when exposed to COM.

GetExceptionCode()
Obsolete.

Retrieves a code that identifies the type of the exception that occurred.

GetExceptionForHR(Int32, IntPtr)

Converts the specified HRESULT error code to a corresponding Exception object, with additional error information passed in an IErrorInfo interface for the exception object.

GetExceptionForHR(Int32)

Converts the specified HRESULT error code to a corresponding Exception object.

GetExceptionPointers()

Retrieves a computer-independent description of an exception, and information about the state that existed for the thread when the exception occurred.

GetFunctionPointerForDelegate(Delegate)
Obsolete.

Converts a delegate into a function pointer that is callable from unmanaged code.

GetFunctionPointerForDelegate<TDelegate>(TDelegate)

Converts a delegate of a specified type to a function pointer that is callable from unmanaged code.

GetHINSTANCE(Module)

Returns the instance handle (HINSTANCE) for the specified module.

GetHRForException(Exception)

Converts the specified exception to an HRESULT.

GetHRForLastWin32Error()

Returns the HRESULT corresponding to the last error incurred by Win32 code executed using Marshal.

GetIDispatchForObject(Object)

Returns an IDispatch interface from a managed object.

GetIDispatchForObjectInContext(Object)

Returns an IDispatch interface pointer from a managed object, if the caller is in the same context as that object.

GetITypeInfoForType(Type)

Returns a ITypeInfo interface from a managed type.

GetIUnknownForObject(Object)

Returns an IUnknown interface from a managed object.

GetIUnknownForObjectInContext(Object)

Returns an IUnknown interface from a managed object, if the caller is in the same context as that object.

GetLastPInvokeError()

Get the last platform invoke error on the current thread.

GetLastPInvokeErrorMessage()

Gets the system error message for the last PInvoke error code.

GetLastSystemError()

Gets the last system error on the current thread.

GetLastWin32Error()

Returns the error code returned by the last unmanaged function that was called using platform invoke that has the SetLastError flag set.

GetManagedThunkForUnmanagedMethodPtr(IntPtr, IntPtr, Int32)
Obsolete.

Gets a pointer to a runtime-generated function that marshals a call from managed to unmanaged code.

GetMethodInfoForComSlot(Type, Int32, ComMemberType)

Retrieves a MemberInfo object for the specified virtual function table (v-table or VTBL) slot.

GetNativeVariantForObject(Object, IntPtr)
Obsolete.

Converts an object to a COM VARIANT.

GetNativeVariantForObject<T>(T, IntPtr)
Obsolete.

Converts an object of a specified type to a COM VARIANT.

GetObjectForIUnknown(IntPtr)

Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.

GetObjectForNativeVariant(IntPtr)
Obsolete.

Converts a COM VARIANT to an object.

GetObjectForNativeVariant<T>(IntPtr)
Obsolete.

Converts a COM VARIANT to an object of a specified type.

GetObjectsForNativeVariants(IntPtr, Int32)
Obsolete.

Converts an array of COM VARIANTs to an array of objects.

GetObjectsForNativeVariants<T>(IntPtr, Int32)
Obsolete.

Converts an array of COM VARIANTs to an array of a specified type.

GetPInvokeErrorMessage(Int32)

Gets the system error message for the supplied error code.

GetStartComSlot(Type)

Gets the first slot in the virtual function table (v-table or VTBL) that contains user-defined methods.

GetThreadFromFiberCookie(Int32)
Obsolete.

Converts a fiber cookie into the corresponding Thread instance.

GetTypedObjectForIUnknown(IntPtr, Type)

Returns a managed object of a specified type that represents a COM object.

GetTypeForITypeInfo(IntPtr)

Converts an unmanaged ITypeInfo object into a managed Type object.

GetTypeFromCLSID(Guid)

Returns the type associated with the specified class identifier (CLSID).

GetTypeInfoName(ITypeInfo)

Retrieves the name of the type represented by an ITypeInfo object.

GetTypeInfoName(UCOMITypeInfo)
Obsolete.

Retrieves the name of the type represented by an ITypeInfo object.

GetTypeLibGuid(ITypeLib)

Retrieves the library identifier (LIBID) of a type library.

GetTypeLibGuid(UCOMITypeLib)
Obsolete.

Retrieves the library identifier (LIBID) of a type library.

GetTypeLibGuidForAssembly(Assembly)

Retrieves the library identifier (LIBID) that is assigned to a type library when it was exported from the specified assembly.

GetTypeLibLcid(ITypeLib)

Retrieves the LCID of a type library.

GetTypeLibLcid(UCOMITypeLib)
Obsolete.

Retrieves the LCID of a type library.

GetTypeLibName(ITypeLib)

Retrieves the name of a type library.

GetTypeLibName(UCOMITypeLib)
Obsolete.

Retrieves the name of a type library.

GetTypeLibVersionForAssembly(Assembly, Int32, Int32)

Retrieves the version number of a type library that will be exported from the specified assembly.

GetUniqueObjectForIUnknown(IntPtr)

Creates a unique Runtime Callable Wrapper (RCW) object for a given IUnknown interface.

GetUnmanagedThunkForManagedMethodPtr(IntPtr, IntPtr, Int32)
Obsolete.

Gets a pointer to a runtime-generated function that marshals a call from unmanaged to managed code.

InitHandle(SafeHandle, IntPtr)

Initializes the underlying handle of a newly created SafeHandle to the provided value.

IsComObject(Object)

Indicates whether a specified object represents a COM object.

IsTypeVisibleFromCom(Type)

Indicates whether a type is visible to COM clients.

NumParamBytes(MethodInfo)

Calculates the number of bytes in unmanaged memory that are required to hold the parameters for the specified method.

OffsetOf(Type, String)
Obsolete.

Returns the field offset of the unmanaged form of the managed class.

OffsetOf<T>(String)

Returns the field offset of the unmanaged form of a specified managed class.

Prelink(MethodInfo)

Executes one-time method setup tasks without calling the method.

PrelinkAll(Type)

Performs a pre-link check for all methods on a class.

PtrToStringAnsi(IntPtr, Int32)

Allocates a managed String, copies a specified number of characters from an unmanaged ANSI or UTF-8 string into it, and widens each character to UTF-16.

PtrToStringAnsi(IntPtr)

Copies all characters up to the first null character from an unmanaged ANSI or UTF-8 string to a managed String, and widens each character to UTF-16.

PtrToStringAuto(IntPtr, Int32)

Allocates a managed String and copies the specified number of characters from a string stored in unmanaged memory into it.

PtrToStringAuto(IntPtr)

Allocates a managed String and copies all characters up to the first null character from a string stored in unmanaged memory into it.

PtrToStringBSTR(IntPtr)

Allocates a managed String and copies a binary string (BSTR) stored in unmanaged memory into it.

PtrToStringUni(IntPtr, Int32)

Allocates a managed String and copies a specified number of characters from an unmanaged Unicode string into it.

PtrToStringUni(IntPtr)

Allocates a managed String and copies all characters up to the first null character from an unmanaged Unicode string into it.

PtrToStringUTF8(IntPtr, Int32)

Allocates a managed String and copies a specified number of bytes from an unmanaged UTF8 string into it.

PtrToStringUTF8(IntPtr)

Allocates a managed String and copies all characters up to the first null character from an unmanaged UTF-8 string into it.

PtrToStructure(IntPtr, Object)
Obsolete.

Marshals data from an unmanaged block of memory to a managed object.

PtrToStructure(IntPtr, Type)
Obsolete.

Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified type.

PtrToStructure<T>(IntPtr, T)

Marshals data from an unmanaged block of memory to a managed object of the specified type.

PtrToStructure<T>(IntPtr)

Marshals data from an unmanaged block of memory to a newly allocated managed object of the type specified by a generic type parameter.

QueryInterface(IntPtr, Guid, IntPtr)

Requests a pointer to a specified interface from a COM object.

ReadByte(IntPtr, Int32)

Reads a single byte at a given offset (or index) from unmanaged memory.

ReadByte(IntPtr)

Reads a single byte from unmanaged memory.

ReadByte(Object, Int32)
Obsolete.

Reads a single byte at a given offset (or index) from unmanaged memory.

ReadInt16(IntPtr, Int32)

Reads a 16-bit signed integer at a given offset from unmanaged memory.

ReadInt16(IntPtr)

Reads a 16-bit signed integer from unmanaged memory.

ReadInt16(Object, Int32)
Obsolete.

Reads a 16-bit signed integer at a given offset from unmanaged memory.

ReadInt32(IntPtr, Int32)

Reads a 32-bit signed integer at a given offset from unmanaged memory.

ReadInt32(IntPtr)

Reads a 32-bit signed integer from unmanaged memory.

ReadInt32(Object, Int32)
Obsolete.

Reads a 32-bit signed integer at a given offset from unmanaged memory.

ReadInt64(IntPtr, Int32)

Reads a 64-bit signed integer at a given offset from unmanaged memory.

ReadInt64(IntPtr)

Reads a 64-bit signed integer from unmanaged memory.

ReadInt64(Object, Int32)
Obsolete.

Reads a 64-bit signed integer at a given offset from unmanaged memory.

ReadIntPtr(IntPtr, Int32)

Reads a processor native sized integer at a given offset from unmanaged memory.

ReadIntPtr(IntPtr)

Reads a processor native-sized integer from unmanaged memory.

ReadIntPtr(Object, Int32)
Obsolete.

Reads a processor native sized integer from unmanaged memory.

ReAllocCoTaskMem(IntPtr, Int32)

Resizes a block of memory previously allocated with AllocCoTaskMem(Int32).

ReAllocHGlobal(IntPtr, IntPtr)

Resizes a block of memory previously allocated with AllocHGlobal(IntPtr).

Release(IntPtr)

Decrements the reference count on the specified interface.

ReleaseComObject(Object)

Decrements the reference count of the Runtime Callable Wrapper (RCW) associated with the specified COM object.

ReleaseThreadCache()
Obsolete.

Releases the thread cache.

SecureStringToBSTR(SecureString)

Allocates an unmanaged binary string (BSTR) and copies the contents of a managed SecureString object into it.

SecureStringToCoTaskMemAnsi(SecureString)

Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.

SecureStringToCoTaskMemUnicode(SecureString)

Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.

SecureStringToGlobalAllocAnsi(SecureString)

Copies the contents of a managed SecureString into unmanaged memory, converting into ANSI format as it copies.

SecureStringToGlobalAllocUnicode(SecureString)

Copies the contents of a managed SecureString object into unmanaged memory.

SetComObjectData(Object, Object, Object)

Sets data referenced by the specified key in the specified COM object.

SetLastPInvokeError(Int32)

Sets the last platform invoke error on the current thread.

SetLastSystemError(Int32)

Sets the last system error on the current thread.

SizeOf(Object)
Obsolete.

Returns the unmanaged size of an object in bytes.

SizeOf(Type)
Obsolete.

Returns the size of an unmanaged type in bytes.

SizeOf<T>()

Returns the size of an unmanaged type in bytes.

SizeOf<T>(T)

Returns the unmanaged size of an object of a specified type in bytes.

StringToBSTR(String)

Allocates a BSTR and copies the contents of a managed String into it.

StringToCoTaskMemAnsi(String)

Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToCoTaskMemAuto(String)

Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToCoTaskMemUni(String)

Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToCoTaskMemUTF8(String)

Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToHGlobalAnsi(String)

Copies the contents of a managed String into unmanaged memory, converting into ANSI format as it copies.

StringToHGlobalAuto(String)

Copies the contents of a managed String into unmanaged memory, converting into ANSI format if required.

StringToHGlobalUni(String)

Copies the contents of a managed String into unmanaged memory.

StructureToPtr(Object, IntPtr, Boolean)
Obsolete.

Marshals data from a managed object to an unmanaged block of memory.

StructureToPtr<T>(T, IntPtr, Boolean)

Marshals data from a managed object of a specified type to an unmanaged block of memory.

ThrowExceptionForHR(Int32, IntPtr)

Throws an exception with a specific failure HRESULT, based on the specified IErrorInfo interface.

ThrowExceptionForHR(Int32)

Throws an exception with a specific failure HRESULT value.

UnsafeAddrOfPinnedArrayElement(Array, Int32)
Obsolete.

Gets the address of the element at the specified index inside the specified array.

UnsafeAddrOfPinnedArrayElement<T>(T[], Int32)

Gets the address of the element at the specified index in an array of a specified type.

WriteByte(IntPtr, Byte)

Writes a single byte value to unmanaged memory.

WriteByte(IntPtr, Int32, Byte)

Writes a single byte value to unmanaged memory at a specified offset.

WriteByte(Object, Int32, Byte)
Obsolete.

Writes a single byte value to unmanaged memory at a specified offset.

WriteInt16(IntPtr, Char)

Writes a character as a 16-bit integer value to unmanaged memory.

WriteInt16(IntPtr, Int16)

Writes a 16-bit integer value to unmanaged memory.

WriteInt16(IntPtr, Int32, Char)

Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

WriteInt16(IntPtr, Int32, Int16)

Writes a 16-bit signed integer value into unmanaged memory at a specified offset.

WriteInt16(Object, Int32, Char)
Obsolete.

Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

WriteInt16(Object, Int32, Int16)
Obsolete.

Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

WriteInt32(IntPtr, Int32, Int32)

Writes a 32-bit signed integer value into unmanaged memory at a specified offset.

WriteInt32(IntPtr, Int32)

Writes a 32-bit signed integer value to unmanaged memory.

WriteInt32(Object, Int32, Int32)
Obsolete.

Writes a 32-bit signed integer value to unmanaged memory at a specified offset.

WriteInt64(IntPtr, Int32, Int64)

Writes a 64-bit signed integer value to unmanaged memory at a specified offset.

WriteInt64(IntPtr, Int64)

Writes a 64-bit signed integer value to unmanaged memory.

WriteInt64(Object, Int32, Int64)
Obsolete.

Writes a 64-bit signed integer value to unmanaged memory at a specified offset.

WriteIntPtr(IntPtr, Int32, IntPtr)

Writes a processor native-sized integer value to unmanaged memory at a specified offset.

WriteIntPtr(IntPtr, IntPtr)

Writes a processor native sized integer value into unmanaged memory.

WriteIntPtr(Object, Int32, IntPtr)
Obsolete.

Writes a processor native sized integer value to unmanaged memory.

ZeroFreeBSTR(IntPtr)

Frees a BSTR pointer that was allocated using the SecureStringToBSTR(SecureString) method.

ZeroFreeCoTaskMemAnsi(IntPtr)

Frees an unmanaged string pointer that was allocated using the SecureStringToCoTaskMemAnsi(SecureString) method.

ZeroFreeCoTaskMemUnicode(IntPtr)

Frees an unmanaged string pointer that was allocated using the SecureStringToCoTaskMemUnicode(SecureString) method.

ZeroFreeCoTaskMemUTF8(IntPtr)

Frees an unmanaged string pointer that was allocated using the StringToCoTaskMemUTF8(String) method.

ZeroFreeGlobalAllocAnsi(IntPtr)

Frees an unmanaged string pointer that was allocated using the SecureStringToGlobalAllocAnsi(SecureString) method.

ZeroFreeGlobalAllocUnicode(IntPtr)

Frees an unmanaged string pointer that was allocated using the SecureStringToGlobalAllocUnicode(SecureString) method.

Applies to