_get_heap_handle

返回 C 运行时系统使用的堆的句柄。

重要

此 API 不能在运行时的窗口执行的应用程序,但在调试版本。有关更多信息,请参见 CRT 函数不支持与 /ZW

intptr_t _get_heap_handle( void );

返回值

将处理返回到 C 运行时系统使用的 Win32 堆。

备注

如果要调用 HeapSetInformation 和启用 CRT 堆,低的碎片堆请使用此功能。

要求

实例

必需的标头

_get_heap_handle

<malloc.h>

有关更多兼容性信息,请参见中介绍的 兼容性

示例

// crt_get_heap_handle.cpp
// compile with: /MT
#include <windows.h>
#include <malloc.h>
#include <stdio.h>

int main(void)
{
    intptr_t hCrtHeap = _get_heap_handle();
    ULONG ulEnableLFH = 2;
    if (HeapSetInformation((PVOID)hCrtHeap,
                           HeapCompatibilityInformation,
                           &ulEnableLFH, sizeof(ulEnableLFH)))
        puts("Enabling Low Fragmentation Heap succeeded");
    else
        puts("Enabling Low Fragmentation Heap failed");
    return 0;
}

请参见

参考

内存分配