捐助郴维网
感谢您对郴维网的支持,你的支持将是郴维网持续发展的动力!
二维码
×
当前位置:郴维网 >API档案 > 正文
8 2017.06

HeapQueryInformation

点击次数:1458 更新时间:2017-6-8 21:56:49  【打印此页

原文链接 -> 传送门

函数功能:

HeapQueryInformation 函数用于获取指定堆的信息。


API 函数原型:

注释:_In_ 说明该参数是输入的,_Out_ 说明该参数是输出的,_opt_ 说明该参数是可选的。

BOOL WINAPI HeapQueryInformation(
  _In_opt_  HANDLE                 HeapHandle,
  _In_      HEAP_INFORMATION_CLASS HeapInformationClass,
  _Out_     PVOID                  HeapInformation,
  _In_      SIZE_T                 HeapInformationLength,
  _Out_opt_ PSIZE_T                ReturnLength
);


参数解析:
 

参数

含义

HeapHandle

1. 指向待获取信息的堆句柄

2. 该句柄由 HeapCreate 函数或者 GetProcessHeap 函数返回获取

HeapInformationClass

1. 指定待获取的堆信息

2. 该参数可以是下列 HEAP_INFORMATION_CLASS 枚举类型之一:

含义

HeapCompatibilityInformation
(0)

1. 表明堆功能特性启用

2. HeapInformation 参数是一个指向 ULONG 类型变量的指针

3. 如果 HeapInformation 为 0,则堆是一个不支持后备链表标准堆

4. 如果 HeapInformation 为 1,则堆是一个支持后备链表堆。更多相关信息,参见备注

5. 如果 HeapInformation 为 2,则启用低碎片堆。开启低碎片堆时禁用后备链表

HeapInformation

1. 指向堆信息缓冲区指针

2. 该数据的格式取决于 HeapInformationClass 参数

HeapInformationLength

指定被查询的堆信息长度,单位字节

ReturnLength

1. 指向接收被写入到 HeapInformation 指向的缓冲区的数据长度指针。如果缓冲区太小,函数调用失败且 ReturnLength 为需要的缓冲区最小值

2. 如果您确实不想接收这个信息,ReturnLength 设为 NULL



返回值:

1. 如果函数调用成功,返回值是非 0;

2. 如果函数调用失败,返回值是 0。

若想获得更多的错误信息,请调用 GetLastError 函数。


备注:

1. 使用 HeapSetInformation 函数启用低碎片堆或堆溢出终止功能特性。

2. Windows XP and Windows Server 2003:

后备链表是一个快速的内存分配机制,但只适用于固定大小的内存块。如果堆支持后备链表,则默认启用。从 Windows Vista 开始,后备链表不使用,低碎片堆默认启用。

后备链表比通用池不同大小的内存分配速度快,因为系统不搜索适合分配的空闲内存。此外,访问后备链表通常使用快速原子处理器交换指令同步,而非互斥或自旋锁。后备链表可以由系统或驱动程序创建。可以从分页池或者未分页池分配。


例子:

下例是使用 GetProcessHeap 函数获取默认进程堆句柄和使用 HeapQueryInformation 函数获取堆信息。

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define HEAP_STANDARD 0
#define HEAP_LAL 1
#define HEAP_LFH 2

int __cdecl _tmain()
{
    BOOL bResult;
    HANDLE hHeap;
    ULONG HeapInformation;

    //
    // Get a handle to the default process heap.
    //
    hHeap = GetProcessHeap();
    if (hHeap == NULL) {
        _tprintf(TEXT("Failed to retrieve default process heap with LastError %d.\n"),
                 GetLastError());
        return 1;
    }

    //
    // Query heap features that are enabled.
    //
    bResult = HeapQueryInformation(hHeap,
                                   HeapCompatibilityInformation,
                                   &HeapInformation,
                                   sizeof(HeapInformation),
                                   NULL);
    if (bResult == FALSE) {
        _tprintf(TEXT("Failed to retrieve heap features with LastError %d.\n"),
                 GetLastError());
        return 1;
    }

    //
    // Print results of the query.
    //
    _tprintf(TEXT("HeapCompatibilityInformation is %d.\n"), HeapInformation);
    switch(HeapInformation)
    {
    case HEAP_STANDARD:
        _tprintf(TEXT("The default process heap is a standard heap.\n"));
        break;
    case HEAP_LAL:
        _tprintf(TEXT("The default process heap supports look-aside lists.\n"));
        break;
    case HEAP_LFH:
        _tprintf(TEXT("The default process heap has the low-fragmentation ") \
                 TEXT("heap enabled.\n"));
        break;
    default:
        _tprintf(TEXT("Unrecognized HeapInformation reported for the default ") \
                 TEXT("process heap.\n"));
        break;
     }

    return 0;
}



需求:
 

Minimum supported client

Windows XP [桌面应用程序 | Windows Store 程序]

Minimum supported server

Windows 2003 服务器版 [桌面应用程序 | Windows Store 程序]

Minimum supported phone

Windows Phone 8

Header

HeapApi.h (包含于 Windows.h);
WinBase.h 在 Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP 上(包含于 Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

提示
郴维网为您提供各类专业服务:
软件开发,电脑配件销售,WIFI路由器销售,上门电脑维修,上门安装系统,系统安装,软、硬件安装,电脑除尘清灰,显示器维修,WIFI安装调试,服务器维护,数据恢复,密码破解,网络布线,网络检修,打印机维修,打印机加碳粉,苹果电脑安装系统,苹果电脑安装双系统,监控安装维护,电脑外包,笔记本电脑维修,餐饮、美容行业软件安装 等。。。。。。
点击次数:1458 更新时间:2017-6-8 21:56:49  【打印此页

上一条:GetDoubleClickTime

下一条:EnumPropsEx

关键词推荐:郴州电脑城 郴州电脑维修公司 维修电脑公司 郴州软件开发 上门电脑维修 上门安装系统 笔记本电脑维修 郴州打印机维修 打印机加碳粉 电脑安装双系统 苹果电脑双系统 液晶显示器维修 联想笔记本维修 联想笔记本维修电话 戴尔笔记本维修电话 郴州戴尔笔记本维修 戴尔笔记本郴州维修点 华硕笔记本维修点 郴州华硕笔记本维修 郴州笔记本上网维修