Marshal.AllocCoTaskMem(Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从 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 是类中两种内存分配 API 方法之 Marshal 一。 (Marshal.AllocHGlobal 是另一种。返回的初始内存内容未定义,分配的内存可以大于请求的字节数。 此方法公开 COM CoTaskMemAlloc 函数,该函数称为 COM 任务内存分配器。