Marshal Marshal Marshal Marshal Class

定義

提供方法的集合,方法用於配置 Unmanaged 記憶體、複製 Unmanaged 記憶體區塊和將 Managed 類型轉換為 Unmanaged 類型,也包括其他和 Unmanaged 程式碼互動時使用的方法。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 static class Marshal
type Marshal = class
Public Class Marshal
繼承
MarshalMarshalMarshalMarshal

範例

下列範例顯示如何使用類別所Marshal定義的各種方法。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

備註

static 類別Marshal上定義的方法,是使用非受控碼時不可或缺的。The static methods defined on the Marshal class are essential to working with unmanaged code. 在此類別中定義的大部分方法,通常是由想要在 managed 和非受控程式設計模型之間提供橋樑的開發人員使用。Most methods defined in this class are typically used by developers who want to provide a bridge between the managed and unmanaged programming models. 例如, StringToHGlobalAnsi方法會從指定的字串(在 managed 堆積中)將 ANSI 字元複製到非受控堆積中的緩衝區。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. 如需封送處理行為的詳細資訊,請參閱Interop 封送處理For details on marshaling behavior, see Interop Marshaling.

類別ReadWrite的和方法Marshal都支援對齊和未對齊的存取。The Read and Write methods in the Marshal class support both aligned and unaligned access.

欄位

SystemDefaultCharSize SystemDefaultCharSize SystemDefaultCharSize SystemDefaultCharSize

表示系統上的預設字元大小;Unicode 系統的預設值為 2,ANSI 系統為 1。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 SystemMaxDBCSCharSize SystemMaxDBCSCharSize SystemMaxDBCSCharSize

表示用於目前作業系統雙位元組字元集 (DBCS) 大小的最大值,以位元組為單位。Represents the maximum size of a double byte character set (DBCS) size, in bytes, for the current operating system. 此欄位為唯讀。This field is read-only.

方法

AddRef(IntPtr) AddRef(IntPtr) AddRef(IntPtr) AddRef(IntPtr)

遞增指定介面的參考次數 (Reference Count)。Increments the reference count on the specified interface.

AllocCoTaskMem(Int32) AllocCoTaskMem(Int32) AllocCoTaskMem(Int32) AllocCoTaskMem(Int32)

從 COM 工作記憶體配置器 (Allocator) 配置指定大小的記憶體區塊。Allocates a block of memory of specified size from the COM task memory allocator.

AllocHGlobal(Int32) AllocHGlobal(Int32) AllocHGlobal(Int32) AllocHGlobal(Int32)

使用指定的位元組數目,從處理序的 Unmanaged 記憶體中配置記憶體。Allocates memory from the unmanaged memory of the process by using the specified number of bytes.

AllocHGlobal(IntPtr) AllocHGlobal(IntPtr) AllocHGlobal(IntPtr) AllocHGlobal(IntPtr)

使用指定數目的位元組指標,從處理序的 Unmanaged 記憶體中配置記憶體。Allocates memory from the unmanaged memory of the process by using the pointer to the specified number of bytes.

AreComObjectsAvailableForCleanup() AreComObjectsAvailableForCleanup() AreComObjectsAvailableForCleanup() AreComObjectsAvailableForCleanup()

表示是否有位在任何內容中的執行階段可呼叫包裝函式 (RCW) 可以清除。Indicates whether runtime callable wrappers (RCWs) from any context are available for cleanup.

BindToMoniker(String) BindToMoniker(String) BindToMoniker(String) BindToMoniker(String)

取得由指定 Moniker 來識別的介面指標。Gets an interface pointer identified by the specified moniker.

BufferToBSTR(Array, Int32) BufferToBSTR(Array, Int32) BufferToBSTR(Array, Int32) BufferToBSTR(Array, Int32)
ChangeWrapperHandleStrength(Object, Boolean) ChangeWrapperHandleStrength(Object, Boolean) ChangeWrapperHandleStrength(Object, Boolean) ChangeWrapperHandleStrength(Object, Boolean)

變更物件之 COM 可呼叫包裝函式 (CCW) 控制代碼的強度。Changes the strength of an object's COM Callable Wrapper (CCW) handle.

CleanupUnusedObjectsInCurrentContext() CleanupUnusedObjectsInCurrentContext() CleanupUnusedObjectsInCurrentContext() CleanupUnusedObjectsInCurrentContext()

通知執行階段清除配置在目前內容中的所有執行階段可呼叫包裝函式 (RCW)。Notifies the runtime to clean up all Runtime Callable Wrappers (RCWs) allocated in the current context.

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

從一維、Managed 單精確度浮點數陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed single-precision floating-point number array to an unmanaged memory pointer.

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

從一維、Managed IntPtr 陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed IntPtr array to an unmanaged memory pointer.

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

從 Unmanaged 記憶體指標將資料複製到 Managed 單精確度浮點數陣列。Copies data from an unmanaged memory pointer to a managed single-precision floating-point number array.

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

從 Unmanaged 記憶體指標將資料複製到 Managed 64 位元帶正負號的整數陣列。Copies data from an unmanaged memory pointer to a managed 64-bit signed integer array.

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

從 Unmanaged 記憶體指標將資料複製到 Managed 32 位元帶正負號的整數陣列。Copies data from an unmanaged memory pointer to a managed 32-bit signed integer array.

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

從 Unmanaged 記憶體指標將資料複製到 Managed 16 位元帶正負號的整數陣列。Copies data from an unmanaged memory pointer to a managed 16-bit signed integer array.

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

從 Unmanaged 記憶體指標將資料複製到Managed 雙精確度浮點數陣列。Copies data from an unmanaged memory pointer to a managed double-precision floating-point number array.

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

從 Unmanaged 記憶體指標,將資料複製到 Managed IntPtr 陣列。Copies data from an unmanaged memory pointer to a managed IntPtr array.

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

從 Unmanaged 記憶體指標將資料複製到 Managed 8 位元不帶正負號的整數 (Unsigned Integer) 陣列。Copies data from an unmanaged memory pointer to a managed 8-bit unsigned integer array.

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

從一維、Managed 64 位元帶正負號的整數陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed 64-bit signed integer array to an unmanaged memory pointer.

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

從一維、Managed 32 位元帶正負號的整數陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointer.

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

從一維、Managed 16 位元帶正負號的整數陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed 16-bit signed integer array to an unmanaged memory pointer.

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

從 Unmanaged 記憶體指標將資料複製到 Managed 字元陣列。Copies data from an unmanaged memory pointer to a managed character array.

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

從一維、Managed 雙精確度浮點數陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed double-precision floating-point number array to an unmanaged memory pointer.

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

從一維、Managed 字元陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed character array to an unmanaged memory pointer.

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

從一維、Managed 8 位元不帶正負號的整數 (Unsigned Integer) 陣列將資料複製到 Unmanaged 記憶體指標。Copies data from a one-dimensional, managed 8-bit unsigned integer array to an unmanaged memory pointer.

CreateAggregatedObject(IntPtr, Object) CreateAggregatedObject(IntPtr, Object) CreateAggregatedObject(IntPtr, Object) CreateAggregatedObject(IntPtr, Object)

將 Managed 物件與指定的 COM 物件進行彙總。Aggregates a managed object with the specified COM object.

CreateAggregatedObject<T>(IntPtr, T) CreateAggregatedObject<T>(IntPtr, T) CreateAggregatedObject<T>(IntPtr, T) CreateAggregatedObject<T>(IntPtr, T)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將所指定類型的 Managed 物件與指定的 COM 物件進行彙總。Aggregates a managed object of the specified type with the specified COM object.

CreateWrapperOfType(Object, Type) CreateWrapperOfType(Object, Type) CreateWrapperOfType(Object, Type) CreateWrapperOfType(Object, Type)

將指定 COM 物件包裝在指定類型的物件中。Wraps the specified COM object in an object of the specified type.

CreateWrapperOfType<T,TWrapper>(T) CreateWrapperOfType<T,TWrapper>(T) CreateWrapperOfType<T,TWrapper>(T) CreateWrapperOfType<T,TWrapper>(T)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將指定 COM 物件包裝在指定類型的物件中。Wraps the specified COM object in an object of the specified type.

DestroyStructure(IntPtr, Type) DestroyStructure(IntPtr, Type) DestroyStructure(IntPtr, Type) DestroyStructure(IntPtr, Type)

釋放指定之 Unmanaged 記憶體區塊指向的所有子結構。Frees all substructures that the specified unmanaged memory block points to.

DestroyStructure<T>(IntPtr) DestroyStructure<T>(IntPtr) DestroyStructure<T>(IntPtr) DestroyStructure<T>(IntPtr)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

釋放指定之 Unmanaged 記憶體區塊指向的所有指定類型的子結構。Frees all substructures of a specified type that the specified unmanaged memory block points to.

FinalReleaseComObject(Object) FinalReleaseComObject(Object) FinalReleaseComObject(Object) FinalReleaseComObject(Object)

藉由將執行階段可呼叫包裝函式 (RCW) 的參考計數設定為 0,釋放對 RCW 的所有參考。Releases all references to a Runtime Callable Wrapper (RCW) by setting its reference count to 0.

FreeBSTR(IntPtr) FreeBSTR(IntPtr) FreeBSTR(IntPtr) FreeBSTR(IntPtr)

使用 COM SysFreeString 函式釋放 BSTRFrees a BSTR using the COM SysFreeString function.

FreeCoTaskMem(IntPtr) FreeCoTaskMem(IntPtr) FreeCoTaskMem(IntPtr) FreeCoTaskMem(IntPtr)

釋放 Unmanaged COM 工作記憶體配置器所配置的記憶體區塊。Frees a block of memory allocated by the unmanaged COM task memory allocator.

FreeHGlobal(IntPtr) FreeHGlobal(IntPtr) FreeHGlobal(IntPtr) FreeHGlobal(IntPtr)

從處理序的 Unmanaged 記憶體釋放先前配置的記憶體。Frees memory previously allocated from the unmanaged memory of the process.

GenerateGuidForType(Type) GenerateGuidForType(Type) GenerateGuidForType(Type) GenerateGuidForType(Type)

傳回指定類型的全域唯一識別項 (GUID),或使用類型程式庫匯出工具 (TlbExp.exe) 使用的演算法來產生 GUID。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) GenerateProgIdForType(Type) GenerateProgIdForType(Type) GenerateProgIdForType(Type)

傳回指定類型的程式設計識別項 (ProgID)。Returns a programmatic identifier (ProgID) for the specified type.

GetActiveObject(String) GetActiveObject(String) GetActiveObject(String) GetActiveObject(String)

從執行物件表格 (Running Object Table,ROT) 取得指定之物件的執行中執行個體。Obtains a running instance of the specified object from the running object table (ROT).

GetComInterfaceForObject(Object, Type) GetComInterfaceForObject(Object, Type) GetComInterfaceForObject(Object, Type) GetComInterfaceForObject(Object, Type)

傳回 IUnknown 介面指標,表示指定物件上的指定介面。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(Object, Type, CustomQueryInterfaceMode) GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode)

傳回 IUnknown 介面指標,表示指定物件上的指定介面。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<T,TInterface>(T) GetComInterfaceForObject<T,TInterface>(T) GetComInterfaceForObject<T,TInterface>(T) GetComInterfaceForObject<T,TInterface>(T)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions] 傳回 IUnknown 介面指標,表示指定類型的物件上的指定介面。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) GetComInterfaceForObjectInContext(Object, Type) GetComInterfaceForObjectInContext(Object, Type) 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) GetComObjectData(Object, Object) GetComObjectData(Object, Object) GetComObjectData(Object, Object)

從指定的 COM 物件擷取指定的索引鍵所參考的資料。Retrieves data that is referenced by the specified key from the specified COM object.

GetComSlotForMethodInfo(MemberInfo) GetComSlotForMethodInfo(MemberInfo) GetComSlotForMethodInfo(MemberInfo) GetComSlotForMethodInfo(MemberInfo)

擷取公開給 COM 時,指定之 MemberInfo 類型的虛擬函式表 (v-table 或 VTBL) 位置。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) GetDelegateForFunctionPointer(IntPtr, Type) GetDelegateForFunctionPointer(IntPtr, Type) GetDelegateForFunctionPointer(IntPtr, Type)

將 Unmanaged 函式指標轉換成委派。Converts an unmanaged function pointer to a delegate.

GetDelegateForFunctionPointer<TDelegate>(IntPtr) GetDelegateForFunctionPointer<TDelegate>(IntPtr) GetDelegateForFunctionPointer<TDelegate>(IntPtr) GetDelegateForFunctionPointer<TDelegate>(IntPtr)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將 Unmanaged 函式指標轉換成所指定類型的委派。Converts an unmanaged function pointer to a delegate of a specified type.

GetEndComSlot(Type) GetEndComSlot(Type) GetEndComSlot(Type) GetEndComSlot(Type)

擷取公開給 COM 時,類型在虛擬函式表 (v-table 或 VTBL) 中的最後一個位置。Retrieves the last slot in the virtual function table (v-table or VTBL) of a type when exposed to COM.

GetExceptionCode() GetExceptionCode() GetExceptionCode() GetExceptionCode()

擷取可辨識發生的例外狀況 (Exception) 類型的代碼。Retrieves a code that identifies the type of the exception that occurred.

GetExceptionForHR(Int32) GetExceptionForHR(Int32) GetExceptionForHR(Int32) GetExceptionForHR(Int32)

將指定的 HRESULT 錯誤碼轉換成對應的 Exception 物件。Converts the specified HRESULT error code to a corresponding Exception object.

GetExceptionForHR(Int32, IntPtr) GetExceptionForHR(Int32, IntPtr) GetExceptionForHR(Int32, IntPtr) GetExceptionForHR(Int32, IntPtr)

將指定的 HRESULT 錯誤碼轉換成對應的 Exception 物件,並將其他錯誤資訊傳入此例外狀況物件的 IErrorInfo 介面。Converts the specified HRESULT error code to a corresponding Exception object, with additional error information passed in an IErrorInfo interface for the exception object.

GetExceptionPointers() GetExceptionPointers() GetExceptionPointers() 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) GetFunctionPointerForDelegate(Delegate) GetFunctionPointerForDelegate(Delegate) GetFunctionPointerForDelegate(Delegate)

將委派轉換成可從 Unmanaged 程式碼呼叫的函式指標。Converts a delegate into a function pointer that is callable from unmanaged code.

GetFunctionPointerForDelegate<TDelegate>(TDelegate) GetFunctionPointerForDelegate<TDelegate>(TDelegate) GetFunctionPointerForDelegate<TDelegate>(TDelegate) GetFunctionPointerForDelegate<TDelegate>(TDelegate)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將所指定類型的委派轉換成可從 Unmanaged 程式碼呼叫的函式指標。Converts a delegate of a specified type to a function pointer that is callable from unmanaged code.

GetHINSTANCE(Module) GetHINSTANCE(Module) GetHINSTANCE(Module) GetHINSTANCE(Module)

傳回指定模組的執行個體控制代碼 (HINSTANCE)。Returns the instance handle (HINSTANCE) for the specified module.

GetHRForException(Exception) GetHRForException(Exception) GetHRForException(Exception) GetHRForException(Exception)

將指定的例外狀況轉換成 HRESULT。Converts the specified exception to an HRESULT.

GetHRForLastWin32Error() GetHRForLastWin32Error() GetHRForLastWin32Error() GetHRForLastWin32Error()

傳回 HRESULT,它對應於使用 Marshal 執行的 Win32 程式碼所引發的最後一個錯誤。Returns the HRESULT corresponding to the last error incurred by Win32 code executed using Marshal.

GetIDispatchForObject(Object) GetIDispatchForObject(Object) GetIDispatchForObject(Object) GetIDispatchForObject(Object)

從 Managed 物件傳回 IDispatch 介面。Returns an IDispatch interface from a managed object.

GetIDispatchForObjectInContext(Object) GetIDispatchForObjectInContext(Object) GetIDispatchForObjectInContext(Object) GetIDispatchForObjectInContext(Object)

從 Managed 物件傳回 IDispatch 介面指標 (如果呼叫端與該物件位於相同內容的話)。Returns an IDispatch interface pointer from a managed object, if the caller is in the same context as that object.

GetITypeInfoForType(Type) GetITypeInfoForType(Type) GetITypeInfoForType(Type) GetITypeInfoForType(Type)

從 Managed 型別傳回 ITypeInfo 介面。Returns a ITypeInfo interface from a managed type.

GetIUnknownForObject(Object) GetIUnknownForObject(Object) GetIUnknownForObject(Object) GetIUnknownForObject(Object)

從 Managed 物件傳回 IUnknown 介面。Returns an IUnknown interface from a managed object.

GetIUnknownForObjectInContext(Object) GetIUnknownForObjectInContext(Object) GetIUnknownForObjectInContext(Object) GetIUnknownForObjectInContext(Object)

從 Managed 物件傳回 IUnknown 介面 (如果呼叫端與該物件位於相同內容的話)。Returns an IUnknown interface from a managed object, if the caller is in the same context as that object.

GetLastWin32Error() GetLastWin32Error() GetLastWin32Error() GetLastWin32Error()

傳回使用平台叫用 (已設定 SetLastError 旗標) 來呼叫的最後 Unmanaged 函式所傳回的錯誤碼。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) GetManagedThunkForUnmanagedMethodPtr(IntPtr, IntPtr, Int32) GetManagedThunkForUnmanagedMethodPtr(IntPtr, IntPtr, Int32) GetManagedThunkForUnmanagedMethodPtr(IntPtr, IntPtr, Int32)

取得執行階段產生的函式指標,該函式會從 Managed 程式碼將呼叫封送處理至 Unmanaged 程式碼。Gets a pointer to a runtime-generated function that marshals a call from managed to unmanaged code.

GetMethodInfoForComSlot(Type, Int32, ComMemberType) GetMethodInfoForComSlot(Type, Int32, ComMemberType) GetMethodInfoForComSlot(Type, Int32, ComMemberType) GetMethodInfoForComSlot(Type, Int32, ComMemberType)

擷取指定之虛擬函式表 (v-table 或 VTBL) 位置的 MemberInfo 物件。Retrieves a MemberInfo object for the specified virtual function table (v-table or VTBL) slot.

GetNativeVariantForObject(Object, IntPtr) GetNativeVariantForObject(Object, IntPtr) GetNativeVariantForObject(Object, IntPtr) GetNativeVariantForObject(Object, IntPtr)

將物件轉換為 COM VARIANT。Converts an object to a COM VARIANT.

GetNativeVariantForObject<T>(T, IntPtr) GetNativeVariantForObject<T>(T, IntPtr) GetNativeVariantForObject<T>(T, IntPtr) GetNativeVariantForObject<T>(T, IntPtr)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將所指定類型的物件轉換成 COM VARIANT。Converts an object of a specified type to a COM VARIANT.

GetObjectForIUnknown(IntPtr) GetObjectForIUnknown(IntPtr) GetObjectForIUnknown(IntPtr) GetObjectForIUnknown(IntPtr)

傳回類型的執行個體,這個執行個體透過 IUnknown 介面指標來表示 COM 物件。Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.

GetObjectForNativeVariant(IntPtr) GetObjectForNativeVariant(IntPtr) GetObjectForNativeVariant(IntPtr) GetObjectForNativeVariant(IntPtr)

將 COM VARIANT 轉換為物件。Converts a COM VARIANT to an object.

GetObjectForNativeVariant<T>(IntPtr) GetObjectForNativeVariant<T>(IntPtr) GetObjectForNativeVariant<T>(IntPtr) GetObjectForNativeVariant<T>(IntPtr)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將 COM VARIANT 轉換為所指定類型的物件。Converts a COM VARIANT to an object of a specified type.

GetObjectsForNativeVariants(IntPtr, Int32) GetObjectsForNativeVariants(IntPtr, Int32) GetObjectsForNativeVariants(IntPtr, Int32) GetObjectsForNativeVariants(IntPtr, Int32)

將 COM VARIANT 的陣列轉換成物件陣列。Converts an array of COM VARIANTs to an array of objects.

GetObjectsForNativeVariants<T>(IntPtr, Int32) GetObjectsForNativeVariants<T>(IntPtr, Int32) GetObjectsForNativeVariants<T>(IntPtr, Int32) GetObjectsForNativeVariants<T>(IntPtr, Int32)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

將 COM VARIANT 的陣列轉換為所指定類型的陣列。Converts an array of COM VARIANTs to an array of a specified type.

GetStartComSlot(Type) GetStartComSlot(Type) GetStartComSlot(Type) GetStartComSlot(Type)

取得虛擬函式表 (v-table 或 VTBL) 中包含使用者定義之方法的第一個位置。Gets the first slot in the virtual function table (v-table or VTBL) that contains user-defined methods.

GetThreadFromFiberCookie(Int32) GetThreadFromFiberCookie(Int32) GetThreadFromFiberCookie(Int32) GetThreadFromFiberCookie(Int32)

將 Fiber Cookie 轉換成對應的 Thread 執行個體。Converts a fiber cookie into the corresponding Thread instance.

GetTypedObjectForIUnknown(IntPtr, Type) GetTypedObjectForIUnknown(IntPtr, Type) GetTypedObjectForIUnknown(IntPtr, Type) GetTypedObjectForIUnknown(IntPtr, Type)

傳回表示 COM 物件之指定類型的 Managed 物件。Returns a managed object of a specified type that represents a COM object.

GetTypeForITypeInfo(IntPtr) GetTypeForITypeInfo(IntPtr) GetTypeForITypeInfo(IntPtr) GetTypeForITypeInfo(IntPtr)

將 Unmanaged ITypeInfo 物件轉換成 Managed Type 物件。Converts an unmanaged ITypeInfo object into a managed Type object.

GetTypeFromCLSID(Guid) GetTypeFromCLSID(Guid) GetTypeFromCLSID(Guid) GetTypeFromCLSID(Guid)

傳回與指定的類別識別項 (CLSID) 關聯的類型。Returns the type associated with the specified class identifier (CLSID).

GetTypeInfoName(UCOMITypeInfo) GetTypeInfoName(UCOMITypeInfo) GetTypeInfoName(UCOMITypeInfo) GetTypeInfoName(UCOMITypeInfo)

擷取以 ITypeInfo 物件表示的類型名稱。Retrieves the name of the type represented by an ITypeInfo object.

GetTypeInfoName(ITypeInfo) GetTypeInfoName(ITypeInfo) GetTypeInfoName(ITypeInfo) GetTypeInfoName(ITypeInfo)

擷取以 ITypeInfo 物件表示的類型名稱。Retrieves the name of the type represented by an ITypeInfo object.

GetTypeLibGuid(ITypeLib) GetTypeLibGuid(ITypeLib) GetTypeLibGuid(ITypeLib) GetTypeLibGuid(ITypeLib)

擷取類型程式庫的程式庫識別項 (LIBID)。Retrieves the library identifier (LIBID) of a type library.

GetTypeLibGuid(UCOMITypeLib) GetTypeLibGuid(UCOMITypeLib) GetTypeLibGuid(UCOMITypeLib) GetTypeLibGuid(UCOMITypeLib)

擷取類型程式庫的程式庫識別項 (LIBID)。Retrieves the library identifier (LIBID) of a type library.

GetTypeLibGuidForAssembly(Assembly) GetTypeLibGuidForAssembly(Assembly) GetTypeLibGuidForAssembly(Assembly) GetTypeLibGuidForAssembly(Assembly)

擷取當它從指定組件 (Assembly) 匯出時指派給類型程式庫的程式庫識別項 (LIBID)。Retrieves the library identifier (LIBID) that is assigned to a type library when it was exported from the specified assembly.

GetTypeLibLcid(ITypeLib) GetTypeLibLcid(ITypeLib) GetTypeLibLcid(ITypeLib) GetTypeLibLcid(ITypeLib)

擷取類型程式庫的 LCID。Retrieves the LCID of a type library.

GetTypeLibLcid(UCOMITypeLib) GetTypeLibLcid(UCOMITypeLib) GetTypeLibLcid(UCOMITypeLib) GetTypeLibLcid(UCOMITypeLib)

擷取類型程式庫的 LCID。Retrieves the LCID of a type library.

GetTypeLibName(ITypeLib) GetTypeLibName(ITypeLib) GetTypeLibName(ITypeLib) GetTypeLibName(ITypeLib)

擷取類型程式庫的名稱。Retrieves the name of a type library.

GetTypeLibName(UCOMITypeLib) GetTypeLibName(UCOMITypeLib) GetTypeLibName(UCOMITypeLib) GetTypeLibName(UCOMITypeLib)

擷取類型程式庫的名稱。Retrieves the name of a type library.

GetTypeLibVersionForAssembly(Assembly, Int32, Int32) GetTypeLibVersionForAssembly(Assembly, Int32, Int32) GetTypeLibVersionForAssembly(Assembly, Int32, Int32) GetTypeLibVersionForAssembly(Assembly, Int32, Int32)

擷取類型程式庫的版本號碼,此程式庫將從指定的組件匯出。Retrieves the version number of a type library that will be exported from the specified assembly.

GetUniqueObjectForIUnknown(IntPtr) GetUniqueObjectForIUnknown(IntPtr) GetUniqueObjectForIUnknown(IntPtr) GetUniqueObjectForIUnknown(IntPtr)

為指定的 IUnknown 介面建立唯一的執行階段可呼叫包裝函式 (RCW) 物件。Creates a unique Runtime Callable Wrapper (RCW) object for a given IUnknown interface.

GetUnmanagedThunkForManagedMethodPtr(IntPtr, IntPtr, Int32) GetUnmanagedThunkForManagedMethodPtr(IntPtr, IntPtr, Int32) GetUnmanagedThunkForManagedMethodPtr(IntPtr, IntPtr, Int32) GetUnmanagedThunkForManagedMethodPtr(IntPtr, IntPtr, Int32)

取得執行階段產生的函式指標,該函式會從 Unmanaged 程式碼將呼叫封送處理至 Managed 程式碼。Gets a pointer to a runtime-generated function that marshals a call from unmanaged to managed code.

IsComObject(Object) IsComObject(Object) IsComObject(Object) IsComObject(Object)

指示指定物件是否表示 COM 物件。Indicates whether a specified object represents a COM object.

IsTypeVisibleFromCom(Type) IsTypeVisibleFromCom(Type) IsTypeVisibleFromCom(Type) IsTypeVisibleFromCom(Type)

指示類型對 COM 用戶端是否為可見的。Indicates whether a type is visible to COM clients.

NumParamBytes(MethodInfo) NumParamBytes(MethodInfo) NumParamBytes(MethodInfo) NumParamBytes(MethodInfo)

計算要儲存指定方法的參數而在 unmanaged 記憶體中所需的位元組數目。Calculates the number of bytes in unmanaged memory that are required to hold the parameters for the specified method.

OffsetOf(Type, String) OffsetOf(Type, String) OffsetOf(Type, String) OffsetOf(Type, String)

傳回 Managed 類別之 Unmanaged 表單的欄位位移 (Offset)。Returns the field offset of the unmanaged form of the managed class.

OffsetOf<T>(String) OffsetOf<T>(String) OffsetOf<T>(String) OffsetOf<T>(String)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

傳回所指定 Managed 類別之 Unmanaged 表單的欄位位移 (Offset)。Returns the field offset of the unmanaged form of a specified managed class.

Prelink(MethodInfo) Prelink(MethodInfo) Prelink(MethodInfo) Prelink(MethodInfo)

不需呼叫方法就執行一次方法設定工作。Executes one-time method setup tasks without calling the method.

PrelinkAll(Type) PrelinkAll(Type) PrelinkAll(Type) PrelinkAll(Type)

對類別上的方法進行連結前檢查。Performs a pre-link check for all methods on a class.

PtrToStringAnsi(IntPtr) PtrToStringAnsi(IntPtr) PtrToStringAnsi(IntPtr) PtrToStringAnsi(IntPtr)

從 Unmanaged ANSI 字串將直到第一個 null 字元的所有字元複製到 Managed String,並且將每個 ANSI 字元擴展為 Unicode。Copies all characters up to the first null character from an unmanaged ANSI string to a managed String, and widens each ANSI character to Unicode.

PtrToStringAnsi(IntPtr, Int32) PtrToStringAnsi(IntPtr, Int32) PtrToStringAnsi(IntPtr, Int32) PtrToStringAnsi(IntPtr, Int32)

配置 Managed String、從 Unmanaged ANSI 字串將指定數目的字元複製到其中,並將每一個 ANSI 字元擴展為 Unicode。Allocates a managed String, copies a specified number of characters from an unmanaged ANSI string into it, and widens each ANSI character to Unicode.

PtrToStringAuto(IntPtr) PtrToStringAuto(IntPtr) PtrToStringAuto(IntPtr) PtrToStringAuto(IntPtr)

配置 Managed String,並從儲存在 Unmanaged 記憶體的字串中將直到第一個 Null 字元的所有字元複製到其中。Allocates a managed String and copies all characters up to the first null character from a string stored in unmanaged memory into it.

PtrToStringAuto(IntPtr, Int32) PtrToStringAuto(IntPtr, Int32) PtrToStringAuto(IntPtr, Int32) PtrToStringAuto(IntPtr, Int32)

配置 Managed String,並且從儲存在 Unmanaged 記憶體中的字串將指定數目的字元複製到其中。Allocates a managed String and copies the specified number of characters from a string stored in unmanaged memory into it.

PtrToStringBSTR(IntPtr) PtrToStringBSTR(IntPtr) PtrToStringBSTR(IntPtr) PtrToStringBSTR(IntPtr)

配置 Managed String,並將儲存在 Unmanaged 記憶體的二進位字串 (BSTR) 複製到其中。Allocates a managed String and copies a binary string (BSTR) stored in unmanaged memory into it.

PtrToStringUni(IntPtr) PtrToStringUni(IntPtr) PtrToStringUni(IntPtr) PtrToStringUni(IntPtr)

配置 Managed String,並從 Unmanaged Unicode 字串將直到第一個 Null 字元的所有字元複製到其中。Allocates a managed String and copies all characters up to the first null character from an unmanaged Unicode string into it.

PtrToStringUni(IntPtr, Int32) PtrToStringUni(IntPtr, Int32) PtrToStringUni(IntPtr, Int32) PtrToStringUni(IntPtr, Int32)

配置 Managed String,並從 Unmanaged Unicode 字串將指定數目的字元複製到其中。Allocates a managed String and copies a specified number of characters from an unmanaged Unicode string into it.

PtrToStringUTF8(IntPtr) PtrToStringUTF8(IntPtr) PtrToStringUTF8(IntPtr) PtrToStringUTF8(IntPtr)
PtrToStringUTF8(IntPtr, Int32) PtrToStringUTF8(IntPtr, Int32) PtrToStringUTF8(IntPtr, Int32) PtrToStringUTF8(IntPtr, Int32)
PtrToStructure(IntPtr, Object) PtrToStructure(IntPtr, Object) PtrToStructure(IntPtr, Object) PtrToStructure(IntPtr, Object)

從 Unmanaged 記憶體區塊封送處理資料到 Managed 物件。Marshals data from an unmanaged block of memory to a managed object.

PtrToStructure(IntPtr, Type) PtrToStructure(IntPtr, Type) PtrToStructure(IntPtr, Type) PtrToStructure(IntPtr, Type)

從 Unmanaged 記憶體區塊封送處理資料到新配置的指定類型的 Managed 物件。Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified type.

PtrToStructure<T>(IntPtr) PtrToStructure<T>(IntPtr) PtrToStructure<T>(IntPtr) PtrToStructure<T>(IntPtr)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

從 Unmanaged 記憶體區塊封送處理資料到新配置的指定類型的 Managed 物件 (其類型是由泛型類型參數所指定)。Marshals data from an unmanaged block of memory to a newly allocated managed object of the type specified by a generic type parameter.

PtrToStructure<T>(IntPtr, T) PtrToStructure<T>(IntPtr, T) PtrToStructure<T>(IntPtr, T) PtrToStructure<T>(IntPtr, T)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

從 Unmanaged 記憶體區塊封送處理資料到指定類型的 Managed 物件。Marshals data from an unmanaged block of memory to a managed object of the specified type.

QueryInterface(IntPtr, Guid, IntPtr) QueryInterface(IntPtr, Guid, IntPtr) QueryInterface(IntPtr, Guid, IntPtr) QueryInterface(IntPtr, Guid, IntPtr)

從 COM 物件要求指定介面的指標。Requests a pointer to a specified interface from a COM object.

ReadByte(IntPtr, Int32) ReadByte(IntPtr, Int32) ReadByte(IntPtr, Int32) ReadByte(IntPtr, Int32)

從 Unmanaged 記憶體讀取在指定位移 (或索引) 的單一位元組。Reads a single byte at a given offset (or index) from unmanaged memory.

ReadByte(Object, Int32) ReadByte(Object, Int32) ReadByte(Object, Int32) ReadByte(Object, Int32)

從 Unmanaged 記憶體讀取在指定位移 (或索引) 的單一位元組。Reads a single byte at a given offset (or index) from unmanaged memory.

ReadByte(IntPtr) ReadByte(IntPtr) ReadByte(IntPtr) ReadByte(IntPtr)

從 Unmanaged 記憶體讀取單一位元組。Reads a single byte from unmanaged memory.

ReadInt16(IntPtr) ReadInt16(IntPtr) ReadInt16(IntPtr) ReadInt16(IntPtr)

從 Unmanaged 記憶體讀取 16 位元帶正負號的整數。Reads a 16-bit signed integer from unmanaged memory.

ReadInt16(IntPtr, Int32) ReadInt16(IntPtr, Int32) ReadInt16(IntPtr, Int32) ReadInt16(IntPtr, Int32)

從 Unmanaged 記憶體中指定位移處讀取 16 位元帶正負號的整數。Reads a 16-bit signed integer at a given offset from unmanaged memory.

ReadInt16(Object, Int32) ReadInt16(Object, Int32) ReadInt16(Object, Int32) ReadInt16(Object, Int32)

從 Unmanaged 記憶體中指定位移處讀取 16 位元帶正負號的整數。Reads a 16-bit signed integer at a given offset from unmanaged memory.

ReadInt32(IntPtr) ReadInt32(IntPtr) ReadInt32(IntPtr) ReadInt32(IntPtr)

從 Unmanaged 記憶體讀取 32 位元帶正負號的整數。Reads a 32-bit signed integer from unmanaged memory.

ReadInt32(IntPtr, Int32) ReadInt32(IntPtr, Int32) ReadInt32(IntPtr, Int32) ReadInt32(IntPtr, Int32)

從 Unmanaged 記憶體中指定位移處讀取 32 位元帶正負號的整數。Reads a 32-bit signed integer at a given offset from unmanaged memory.

ReadInt32(Object, Int32) ReadInt32(Object, Int32) ReadInt32(Object, Int32) ReadInt32(Object, Int32)

從 Unmanaged 記憶體中指定位移處讀取 32 位元帶正負號的整數。Reads a 32-bit signed integer at a given offset from unmanaged memory.

ReadInt64(IntPtr) ReadInt64(IntPtr) ReadInt64(IntPtr) ReadInt64(IntPtr)

從 Unmanaged 記憶體讀取 64 位元帶正負號的整數。Reads a 64-bit signed integer from unmanaged memory.

ReadInt64(IntPtr, Int32) ReadInt64(IntPtr, Int32) ReadInt64(IntPtr, Int32) ReadInt64(IntPtr, Int32)

從 Unmanaged 記憶體中指定位移處讀取 64 位元帶正負號的整數。Reads a 64-bit signed integer at a given offset from unmanaged memory.

ReadInt64(Object, Int32) ReadInt64(Object, Int32) ReadInt64(Object, Int32) ReadInt64(Object, Int32)

從 Unmanaged 記憶體中指定位移處讀取 64 位元帶正負號的整數。Reads a 64-bit signed integer at a given offset from unmanaged memory.

ReadIntPtr(IntPtr, Int32) ReadIntPtr(IntPtr, Int32) ReadIntPtr(IntPtr, Int32) ReadIntPtr(IntPtr, Int32)

從 Unmanaged 記憶體中指定位移處讀取處理器原生大小的整數。Reads a processor native sized integer at a given offset from unmanaged memory.

ReadIntPtr(Object, Int32) ReadIntPtr(Object, Int32) ReadIntPtr(Object, Int32) ReadIntPtr(Object, Int32)

從 Unmanaged 記憶體讀取處理器原生大小的整數。Reads a processor native sized integer from unmanaged memory.

ReadIntPtr(IntPtr) ReadIntPtr(IntPtr) ReadIntPtr(IntPtr) ReadIntPtr(IntPtr)

從 Unmanaged 記憶體讀取處理器原生大小的整數。Reads a processor native-sized integer from unmanaged memory.

ReAllocCoTaskMem(IntPtr, Int32) ReAllocCoTaskMem(IntPtr, Int32) ReAllocCoTaskMem(IntPtr, Int32) ReAllocCoTaskMem(IntPtr, Int32)

調整先前用 AllocCoTaskMem(Int32) 所配置的記憶體區塊的大小。Resizes a block of memory previously allocated with AllocCoTaskMem(Int32).

ReAllocHGlobal(IntPtr, IntPtr) ReAllocHGlobal(IntPtr, IntPtr) ReAllocHGlobal(IntPtr, IntPtr) ReAllocHGlobal(IntPtr, IntPtr)

調整先前用 AllocHGlobal(IntPtr) 所配置的記憶體區塊的大小。Resizes a block of memory previously allocated with AllocHGlobal(IntPtr).

Release(IntPtr) Release(IntPtr) Release(IntPtr) Release(IntPtr)

遞減指定介面上的參考次數。Decrements the reference count on the specified interface.

ReleaseComObject(Object) ReleaseComObject(Object) ReleaseComObject(Object) ReleaseComObject(Object)

遞減與指定 COM 物件建立關聯之執行階段可呼叫包裝函式 (RCW) 的參考計數。Decrements the reference count of the Runtime Callable Wrapper (RCW) associated with the specified COM object.

ReleaseThreadCache() ReleaseThreadCache() ReleaseThreadCache() ReleaseThreadCache()

釋放執行緒快取。Releases the thread cache.

SecureStringToBSTR(SecureString) SecureStringToBSTR(SecureString) SecureStringToBSTR(SecureString) SecureStringToBSTR(SecureString)

配置 Unmanaged 二進位字串 (BSTR),並將 Managed SecureString 物件的內容複製到其中。Allocates an unmanaged binary string (BSTR) and copies the contents of a managed SecureString object into it.

SecureStringToCoTaskMemAnsi(SecureString) SecureStringToCoTaskMemAnsi(SecureString) SecureStringToCoTaskMemAnsi(SecureString) SecureStringToCoTaskMemAnsi(SecureString)

將 Managed SecureString 物件的內容複製到從 Unmanaged COM 工作配置器配置的記憶體區塊。Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.

SecureStringToCoTaskMemUnicode(SecureString) SecureStringToCoTaskMemUnicode(SecureString) SecureStringToCoTaskMemUnicode(SecureString) SecureStringToCoTaskMemUnicode(SecureString)

將 Managed SecureString 物件的內容複製到從 Unmanaged COM 工作配置器配置的記憶體區塊。Copies the contents of a managed SecureString object to a block of memory allocated from the unmanaged COM task allocator.

SecureStringToGlobalAllocAnsi(SecureString) SecureStringToGlobalAllocAnsi(SecureString) SecureStringToGlobalAllocAnsi(SecureString) SecureStringToGlobalAllocAnsi(SecureString)

將 Managed SecureString 的內容複製到 Unmanaged 記憶體中,並在它複製時轉換成 ANSI 格式。Copies the contents of a managed SecureString into unmanaged memory, converting into ANSI format as it copies.

SecureStringToGlobalAllocUnicode(SecureString) SecureStringToGlobalAllocUnicode(SecureString) SecureStringToGlobalAllocUnicode(SecureString) SecureStringToGlobalAllocUnicode(SecureString)

將 Managed SecureString 物件的內容複製到 Unmanaged 記憶體中。Copies the contents of a managed SecureString object into unmanaged memory.

SetComObjectData(Object, Object, Object) SetComObjectData(Object, Object, Object) SetComObjectData(Object, Object, Object) SetComObjectData(Object, Object, Object)

設定指定COM 物件中指定索引所參考的資料。Sets data referenced by the specified key in the specified COM object.

SizeOf(Object) SizeOf(Object) SizeOf(Object) SizeOf(Object)

傳回物件的 Unmanaged 大小 (以位元組為單位)。Returns the unmanaged size of an object in bytes.

SizeOf(Type) SizeOf(Type) SizeOf(Type) SizeOf(Type)

傳回 Unmanaged 類型的大小 (以位元組為單位)。Returns the size of an unmanaged type in bytes.

SizeOf<T>() SizeOf<T>() SizeOf<T>() SizeOf<T>()

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

傳回 Unmanaged 類型的大小 (以位元組為單位)。Returns the size of an unmanaged type in bytes.

SizeOf<T>(T) SizeOf<T>(T) SizeOf<T>(T) SizeOf<T>(T)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

傳回指定類型之物件的 Unmanaged 大小,以位元組為單位。Returns the unmanaged size of an object of a specified type in bytes.

StringToBSTR(String) StringToBSTR(String) StringToBSTR(String) StringToBSTR(String)

配置 BSTR,並將 Managed String 的內容複製到其中。Allocates a BSTR and copies the contents of a managed String into it.

StringToCoTaskMemAnsi(String) StringToCoTaskMemAnsi(String) StringToCoTaskMemAnsi(String) StringToCoTaskMemAnsi(String)

複製 Managed String 的內容到從 Unmanaged COM 工作配置器配置的記憶體區塊。Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToCoTaskMemAuto(String) StringToCoTaskMemAuto(String) StringToCoTaskMemAuto(String) StringToCoTaskMemAuto(String)

複製 Managed String 的內容到從 Unmanaged COM 工作配置器配置的記憶體區塊。Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToCoTaskMemUni(String) StringToCoTaskMemUni(String) StringToCoTaskMemUni(String) StringToCoTaskMemUni(String)

複製 Managed String 的內容到從 Unmanaged COM 工作配置器配置的記憶體區塊。Copies the contents of a managed String to a block of memory allocated from the unmanaged COM task allocator.

StringToCoTaskMemUTF8(String) StringToCoTaskMemUTF8(String) StringToCoTaskMemUTF8(String) StringToCoTaskMemUTF8(String)
StringToHGlobalAnsi(String) StringToHGlobalAnsi(String) StringToHGlobalAnsi(String) StringToHGlobalAnsi(String)

將 Managed String 的內容複製到 Unmanaged 記憶體中,並在它複製時轉換成 ANSI 格式。Copies the contents of a managed String into unmanaged memory, converting into ANSI format as it copies.

StringToHGlobalAuto(String) StringToHGlobalAuto(String) StringToHGlobalAuto(String) StringToHGlobalAuto(String)

複製 Managed String 的內容到 Unmanaged 記憶體中,如有需要則轉換成 ANSI 格式。Copies the contents of a managed String into unmanaged memory, converting into ANSI format if required.

StringToHGlobalUni(String) StringToHGlobalUni(String) StringToHGlobalUni(String) StringToHGlobalUni(String)

將 Managed String 的內容複製到 Unmanaged 記憶體。Copies the contents of a managed String into unmanaged memory.

StructureToPtr(Object, IntPtr, Boolean) StructureToPtr(Object, IntPtr, Boolean) StructureToPtr(Object, IntPtr, Boolean) StructureToPtr(Object, IntPtr, Boolean)

從 Managed 物件封送處理資料到 Unmanaged 記憶體區塊。Marshals data from a managed object to an unmanaged block of memory.

StructureToPtr<T>(T, IntPtr, Boolean) StructureToPtr<T>(T, IntPtr, Boolean) StructureToPtr<T>(T, IntPtr, Boolean) StructureToPtr<T>(T, IntPtr, Boolean)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

從指定類型的 Managed 物件封送處理資料到 Unmanaged 記憶體區塊。Marshals data from a managed object of a specified type to an unmanaged block of memory.

ThrowExceptionForHR(Int32) ThrowExceptionForHR(Int32) ThrowExceptionForHR(Int32) ThrowExceptionForHR(Int32)

擲回具有特定錯誤 HRESULT 值的例外狀況。Throws an exception with a specific failure HRESULT value.

ThrowExceptionForHR(Int32, IntPtr) ThrowExceptionForHR(Int32, IntPtr) ThrowExceptionForHR(Int32, IntPtr) ThrowExceptionForHR(Int32, IntPtr)

根據指定的 IErrorInfo.aspx) 介面,擲回具有特定失敗 HRESULT 的例外狀況。Throws an exception with a specific failure HRESULT, based on the specified IErrorInfo.aspx) interface.

UnsafeAddrOfPinnedArrayElement(Array, Int32) UnsafeAddrOfPinnedArrayElement(Array, Int32) UnsafeAddrOfPinnedArrayElement(Array, Int32) UnsafeAddrOfPinnedArrayElement(Array, Int32)

取得指定陣列內指定索引處的元素的位址。Gets the address of the element at the specified index inside the specified array.

UnsafeAddrOfPinnedArrayElement<T>(T[], Int32) UnsafeAddrOfPinnedArrayElement<T>(T[], Int32) UnsafeAddrOfPinnedArrayElement<T>(T[], Int32) UnsafeAddrOfPinnedArrayElement<T>(T[], Int32)

[在 .NET Framework 4.5.1 及更新版本中支援][Supported in the .NET Framework 4.5.1 and later versions]

在指定類型的陣列中取得位於指定索引處的元素的位址。Gets the address of the element at the specified index in an array of a specified type.

WriteByte(Object, Int32, Byte) WriteByte(Object, Int32, Byte) WriteByte(Object, Int32, Byte) WriteByte(Object, Int32, Byte)

將單一位元組值寫入 Unmanaged 記憶體中的指定位移。Writes a single byte value to unmanaged memory at a specified offset.

WriteByte(IntPtr, Int32, Byte) WriteByte(IntPtr, Int32, Byte) WriteByte(IntPtr, Int32, Byte) WriteByte(IntPtr, Int32, Byte)

將單一位元組值寫入 Unmanaged 記憶體中的指定位移。Writes a single byte value to unmanaged memory at a specified offset.

WriteByte(IntPtr, Byte) WriteByte(IntPtr, Byte) WriteByte(IntPtr, Byte) WriteByte(IntPtr, Byte)

將單一位元組值寫入 Unmanaged 記憶體。Writes a single byte value to unmanaged memory.

WriteInt16(IntPtr, Char) WriteInt16(IntPtr, Char) WriteInt16(IntPtr, Char) WriteInt16(IntPtr, Char)

將字元當做 16 位元整數值寫入 Unmanaged 記憶體中。Writes a character as a 16-bit integer value to unmanaged memory.

WriteInt16(IntPtr, Int16) WriteInt16(IntPtr, Int16) WriteInt16(IntPtr, Int16) WriteInt16(IntPtr, Int16)

將 16 位元整數值寫入 Unmanaged 記憶體中。Writes a 16-bit integer value to unmanaged memory.

WriteInt16(IntPtr, Int32, Char) WriteInt16(IntPtr, Int32, Char) WriteInt16(IntPtr, Int32, Char) WriteInt16(IntPtr, Int32, Char)

在指定的位移,將 16 位元帶正負號的整數值寫入 Unmanaged 記憶體。Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

WriteInt16(IntPtr, Int32, Int16) WriteInt16(IntPtr, Int32, Int16) WriteInt16(IntPtr, Int32, Int16) WriteInt16(IntPtr, Int32, Int16)

將 16 位元帶正負號的整數值寫入 Unmanaged 記憶體中的指定位移。Writes a 16-bit signed integer value into unmanaged memory at a specified offset.

WriteInt16(Object, Int32, Char) WriteInt16(Object, Int32, Char) WriteInt16(Object, Int32, Char) WriteInt16(Object, Int32, Char)

在指定的位移,將 16 位元帶正負號的整數值寫入 Unmanaged 記憶體。Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

WriteInt16(Object, Int32, Int16) WriteInt16(Object, Int32, Int16) WriteInt16(Object, Int32, Int16) WriteInt16(Object, Int32, Int16)

在指定的位移,將 16 位元帶正負號的整數值寫入 Unmanaged 記憶體。Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

WriteInt32(IntPtr, Int32) WriteInt32(IntPtr, Int32) WriteInt32(IntPtr, Int32) WriteInt32(IntPtr, Int32)

將 32 位元帶正負號的整數值寫入 Unmanaged 記憶體中。Writes a 32-bit signed integer value to unmanaged memory.

WriteInt32(IntPtr, Int32, Int32) WriteInt32(IntPtr, Int32, Int32) WriteInt32(IntPtr, Int32, Int32) WriteInt32(IntPtr, Int32, Int32)

將 32 位元帶正負號的整數值寫入 Unmanaged 記憶體中的指定位移。Writes a 32-bit signed integer value into unmanaged memory at a specified offset.

WriteInt32(Object, Int32, Int32) WriteInt32(Object, Int32, Int32) WriteInt32(Object, Int32, Int32) WriteInt32(Object, Int32, Int32)

在指定的位移,將 32 位元帶正負號的整數值寫入 Unmanaged 記憶體。Writes a 32-bit signed integer value to unmanaged memory at a specified offset.

WriteInt64(Object, Int32, Int64) WriteInt64(Object, Int32, Int64) WriteInt64(Object, Int32, Int64) WriteInt64(Object, Int32, Int64)

在指定的位移,將 64 位元帶正負號的整數值寫入 Unmanaged 記憶體。Writes a 64-bit signed integer value to unmanaged memory at a specified offset.

WriteInt64(IntPtr, Int64) WriteInt64(IntPtr, Int64) WriteInt64(IntPtr, Int64) WriteInt64(IntPtr, Int64)

將 64 位元帶正負號的整數值寫入 Unmanaged 記憶體中。Writes a 64-bit signed integer value to unmanaged memory.

WriteInt64(IntPtr, Int32, Int64) WriteInt64(IntPtr, Int32, Int64) WriteInt64(IntPtr, Int32, Int64) WriteInt64(IntPtr, Int32, Int64)

在指定的位移,將 64 位元帶正負號的整數值寫入 Unmanaged 記憶體。Writes a 64-bit signed integer value to unmanaged memory at a specified offset.

WriteIntPtr(IntPtr, IntPtr) WriteIntPtr(IntPtr, IntPtr) WriteIntPtr(IntPtr, IntPtr) WriteIntPtr(IntPtr, IntPtr)

將處理器原來大小的整數值寫入 Unmanaged 記憶體。Writes a processor native sized integer value into unmanaged memory.

WriteIntPtr(IntPtr, Int32, IntPtr) WriteIntPtr(IntPtr, Int32, IntPtr) WriteIntPtr(IntPtr, Int32, IntPtr) WriteIntPtr(IntPtr, Int32, IntPtr)

將處理器原生大小的整數值寫入 Unmanaged 記憶體中的指定位移。Writes a processor native-sized integer value to unmanaged memory at a specified offset.

WriteIntPtr(Object, Int32, IntPtr) WriteIntPtr(Object, Int32, IntPtr) WriteIntPtr(Object, Int32, IntPtr) WriteIntPtr(Object, Int32, IntPtr)

將處理器原來大小的整數值寫入 Unmanaged 記憶體。Writes a processor native sized integer value to unmanaged memory.

ZeroFreeBSTR(IntPtr) ZeroFreeBSTR(IntPtr) ZeroFreeBSTR(IntPtr) ZeroFreeBSTR(IntPtr)

釋放之前使用 SecureStringToBSTR(SecureString) 方法配置的 BSTR 指標。Frees a BSTR pointer that was allocated using the SecureStringToBSTR(SecureString) method.

ZeroFreeCoTaskMemAnsi(IntPtr) ZeroFreeCoTaskMemAnsi(IntPtr) ZeroFreeCoTaskMemAnsi(IntPtr) ZeroFreeCoTaskMemAnsi(IntPtr)

釋放之前使用 SecureStringToCoTaskMemAnsi(SecureString) 方法配置的 Unmanaged 字串指標。Frees an unmanaged string pointer that was allocated using the SecureStringToCoTaskMemAnsi(SecureString) method.

ZeroFreeCoTaskMemUnicode(IntPtr) ZeroFreeCoTaskMemUnicode(IntPtr) ZeroFreeCoTaskMemUnicode(IntPtr) ZeroFreeCoTaskMemUnicode(IntPtr)

釋放之前使用 SecureStringToCoTaskMemUnicode(SecureString) 方法配置的 Unmanaged 字串指標。Frees an unmanaged string pointer that was allocated using the SecureStringToCoTaskMemUnicode(SecureString) method.

ZeroFreeCoTaskMemUTF8(IntPtr) ZeroFreeCoTaskMemUTF8(IntPtr) ZeroFreeCoTaskMemUTF8(IntPtr) ZeroFreeCoTaskMemUTF8(IntPtr)
ZeroFreeGlobalAllocAnsi(IntPtr) ZeroFreeGlobalAllocAnsi(IntPtr) ZeroFreeGlobalAllocAnsi(IntPtr) ZeroFreeGlobalAllocAnsi(IntPtr)

釋放之前使用 SecureStringToGlobalAllocAnsi(SecureString) 方法配置的 Unmanaged 字串指標。Frees an unmanaged string pointer that was allocated using the SecureStringToGlobalAllocAnsi(SecureString) method.

ZeroFreeGlobalAllocUnicode(IntPtr) ZeroFreeGlobalAllocUnicode(IntPtr) ZeroFreeGlobalAllocUnicode(IntPtr) ZeroFreeGlobalAllocUnicode(IntPtr)

釋放之前使用 SecureStringToGlobalAllocUnicode(SecureString) 方法配置的 Unmanaged 字串指標。Frees an unmanaged string pointer that was allocated using the SecureStringToGlobalAllocUnicode(SecureString) method.

適用於