Marshal.AllocCoTaskMem(Int32) 方法

定義

從 COM 任務記憶體分配器分配指定大小的記憶體區塊。

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 是該類別中 Marshal 兩種記憶體配置 API 方法之一。 (Marshal.AllocHGlobal 是另一個。)回傳的初始記憶體內容未定義,且分配的記憶體可大於請求的位元組數。 此方法揭露了 COM CoTaskMemAlloc 函數,稱為 COM 任務記憶體分配器。

適用於

另請參閱