Kernel32HeapSize Method

Retrieves the size of a memory block allocated from a heap by the HeapAlloc(IntPtr, HeapFlags, UInt32) or HeapReAlloc(IntPtr, HeapFlags, IntPtr, UInt32) function.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", SetLastError = true)]
public static int HeapSize(
	IntPtr hHeap,
	HeapFlags flags,
	IntPtr mem
)

Parameters

hHeap  IntPtr
A handle to the heap in which the memory block resides.

This handle is returned by either the HeapCreate(HeapFlags, UInt32, UInt32) or GetProcessHeap function.

flags  HeapFlags
The heap size options.

Specifying a HeapFlags value overrides the corresponding value specified in the options parameter when the heap was created by using the HeapCreate(HeapFlags, UInt32, UInt32) function.

mem  IntPtr
A pointer to the memory block whose size the function will obtain.

This is a pointer returned by the HeapAlloc(IntPtr, HeapFlags, UInt32) or HeapReAlloc(IntPtr, HeapFlags, IntPtr, UInt32) function.

The memory block must be from the heap specified by the hHeap parameter.

Return Value

Int32
If the function succeeds, the return value is the requested size of the allocated memory block, in bytes.

If the function fails, the return value is (SIZE_T)-1.

The function does not call SetLastError(Win32ErrorCode). An application cannot call GetLastWin32Error for extended error information.

If the mem parameter refers to a heap allocation that is not in the heap specified by the hHeap parameter, the behavior of the HeapSize(IntPtr, HeapFlags, IntPtr) function is undefined.

Remarks

See Also