Marshal.ReAllocHGlobal(IntPtr, IntPtr) 方法

定義

調整先前用 AllocHGlobal(IntPtr) 所配置的記憶體區塊的大小。

public:
 static IntPtr ReAllocHGlobal(IntPtr pv, IntPtr cb);
[System.Security.SecurityCritical]
public static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
public static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb);
[<System.Security.SecurityCritical>]
static member ReAllocHGlobal : nativeint * nativeint -> nativeint
static member ReAllocHGlobal : nativeint * nativeint -> nativeint
Public Shared Function ReAllocHGlobal (pv As IntPtr, cb As IntPtr) As IntPtr

參數

pv
IntPtr

nativeint

AllocHGlobal(IntPtr) 所配置之記憶體的指標。

cb
IntPtr

nativeint

配置的區塊的新大小。 這不是指標;它是您所要求、轉換成 IntPtr 類型的位元組計數。 如果您傳遞指標,它會被視為大小。

傳回

IntPtr

nativeint

重新配置的記憶體的指標。 這個記憶體必須使用 FreeHGlobal(IntPtr) 來釋放。

屬性

例外狀況

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

備註

ReAllocHGlobal 是 類別中兩個記憶體重新配置 API 方法的 Marshal 其中一個。 (Marshal.ReAllocCoTaskMem 是 other.)

這個方法會從 Kernel32.dll 公開 Win32 GlobalReAlloc 函式。 傳回的指標可能與原始指標不同。 如果不同,原始記憶體區塊的內容已複製到新的區塊,而且已釋放原始記憶體區塊。

適用於

另請參閱