Marshal.AllocCoTaskMem(Int32) 方法

定義

從 COM 工作記憶體配置器 (Allocator) 配置指定大小的記憶體區塊。

public:
 static IntPtr AllocCoTaskMem(int cb);
[System.Security.SecurityCritical]
public static IntPtr AllocCoTaskMem (int cb);
public static IntPtr AllocCoTaskMem (int cb);
[<System.Security.SecurityCritical>]
static member AllocCoTaskMem : int -> nativeint
static member AllocCoTaskMem : int -> nativeint
Public Shared Function AllocCoTaskMem (cb As Integer) As IntPtr

參數

cb
Int32

要配置的記憶體區塊的大小。

傳回

IntPtr

nativeint

表示配置的記憶體區塊位址的整數。 這個記憶體必須使用 FreeCoTaskMem(IntPtr) 來釋放。

屬性

例外狀況

記憶體不足,無法滿足要求。

備註

AllocCoTaskMem 是類別中兩個記憶體配置 API 方法的 Marshal 其中一個。 Marshal.AllocHGlobal (是 other.) 傳回的初始記憶體內容未定義,且配置的記憶體可以大於要求的位元組數目。 這個方法會公開 COM CoTaskMemAlloc 函式,稱為 COM 工作記憶體配置器。

適用於

另請參閱