网站首页  词典首页

请输入您要查询的函数:

 

术语 heapsetinformation
释义 HeapSetInformation
语法:
C++
BOOL WINAPI HeapSetInformation(
__in_opt HANDLE HeapHandle,
__in HEAP_INFORMATION_CLASS HeapInformationClass,
__in PVOID HeapInformation,
__in SIZE_T HeapInformationLength
);
HeapSetInformation功能
启用一个指定的堆的功能。
参数
HeapHandle [中,可选]
阿堆句柄信息的情况下被设置。这是处理无论是HeapCreate或GetProcessHeap函数返回。
HeapInformationClass [in]
类的信息要设置。此参数可从HEAP_INFORMATION_CLASS枚举类型为下列值之一。
ValueMeaning
HeapCompatibilityInformation
0Enables堆功能。只有低碎片堆(LFH)的支持。但是,它是没有必要的申请,使LFH,因为系统使用与服务所需的内存分配请求LFH。
Windows XP中的Windows Server 2003和Windows 2000修复KB 816542:
该LFH不是默认启用。为使指定的堆LFH,设置变量指向的HeapInformation参数为2。之后LFH是堆启用,它不能被禁用。
该LFH不能启用或与HEAP_NO_SERIALIZE为创建一个固定大小的堆创建堆。该LFH也不能启用,如果您使用的是堆在调试调试Windows或Microsoft应用程序验证程序工具的工具。
当一个进程是任何调试器中运行,某些堆调试选项会自动启用进程中的所有堆。这些堆调试选项防止LFH使用。为了使低碎片堆在调试器下运行,设置_NO_DEBUG_HEAP环境变量为1。
HeapEnableTerminationOnCorruption
1Enables的终止对腐败的功能。如果堆管理器检测到由堆过程中使用的任何错误,它会调用Windows错误报告服务并终止进程。
经过一个过程,使这一功能,它不能被禁用。
Windows Server 2003和Windows XP/2000操作系统:此值不支持,直到Windows Vista和Windows XP的SP3中。函数调用成功,但HeapEnableTerminationOnCorruption值会被忽略。
HeapInformation [in]
堆信息的缓冲区。这些数据的格式取决于该HeapInformationClass参数的值。
如果HeapInformationClass参数HeapCompatibilityInformation的HeapInformation参数是一个受ULONG变量的指针。
如果HeapInformationClass参数HeapEnableTerminationOnCorruption的HeapInformation参数应为NULL和HeapInformationLength应该是0
HeapInformationLength [in]
该HeapInformation缓冲区大小,以字节为单位。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值为0(零)。为了获得更多错误信息,调用GetLastError。
备注
来获取堆的当前设置,使用HeapQueryInformation功能。
设置HeapEnableTerminateOnCorruption选项强烈建议,因为它减少了应用程序的安全漏洞暴露的需损坏堆的优势。
要使用带有Service Pack 4(SP4)中,这个功能安装在KB 816542中描述的修复程序在Windows 2000。
实例
下面的例子说明了如何使低碎片堆。
#include
#include
#include
#define HEAP_LFH 2
int __cdecl _tmain()
{
BOOL bResult;
HANDLE hHeap;
ULONG HeapInformation;
//
// Note: The HeapSetInformation function is available on Windows 2000 with SP4
// only if hotfix KB 816542 is installed. To run this example on Windows 2000,
// use GetProcAddress to get a pointer to the function if available.
//
//
// Enable heap terminate-on-corruption.
// A correct application can continue to run even if this call fails,
// so it is safe to ignore the return value and call the function as follows:
// (void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
// If the application requires heap terminate-on-corruption to be enabled,
// check the return value and exit on failure as shown in this example.
//
bResult = HeapSetInformation(NULL,
HeapEnableTerminationOnCorruption,
NULL,
0);
if (bResult != FALSE) {
_tprintf(TEXT("Heap terminate-on-corruption has been enabled.\\n"));
}
else {
_tprintf(TEXT("Failed to enable heap terminate-on-corruption with LastError %d.\\n"),
GetLastError());
return 1;
}
//
// Create a new heap with default parameters.
//
hHeap = HeapCreate(0, 0, 0);
if (hHeap == NULL) {
_tprintf(TEXT("Failed to create a new heap with LastError %d.\\n"),
GetLastError());
return 1;
}
//
// Enable the low-fragmenation heap (LFH). Starting with Windows Vista,
// the LFH is enabled by default but this call does not cause an error.
//
HeapInformation = HEAP_LFH;
bResult = HeapSetInformation(hHeap,
HeapCompatibilityInformation,
&HeapInformation,
sizeof(HeapInformation));
if (bResult != FALSE) {
_tprintf(TEXT("The low-fragmentation heap has been enabled.\\n"));
}
else {
_tprintf(TEXT("Failed to enable the low-fragmentation heap with LastError %d.\\n"),
GetLastError());
return 1;
}
return 0;
}
要求:
最低支持clientWindows带有SP4 XP中,Windows 2000专业版
最低支持serverWindows服务器2003
VersionKB在Windows 2000 816542带有SP4
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
GetProcessHeap
堆函数
HeapCreate
HeapQueryInformation
内存管理功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==HeapSetInformation Function
Enables features for a specified heap.
Syntax
C++
BOOL WINAPI HeapSetInformation(
__in_opt HANDLE HeapHandle,
__in HEAP_INFORMATION_CLASS HeapInformationClass,
__in PVOID HeapInformation,
__in SIZE_T HeapInformationLength
);
Parameters
HeapHandle [in, optional]
A handle to the heap where information is to be set. This handle is returned by either the HeapCreate or GetProcessHeap function.
HeapInformationClass [in]
The class of information to be set. This parameter can be one of the following values from the HEAP_INFORMATION_CLASS enumeration type.
ValueMeaning
HeapCompatibilityInformation
0Enables heap features. Only the low-fragmentation heap (LFH) is supported. However, it is not necessary for applications to enable the LFH because the system uses the LFH as needed to service memory allocation requests.
Windows XP, Windows Server 2003, and Windows 2000 with hotfix KB 816542 :
The LFH is not enabled by default. To enable the LFH for the specified heap, set the variable pointed to by the HeapInformation parameter to 2. After the LFH is enabled for a heap, it cannot be disabled.
The LFH cannot be enabled for heaps created with HEAP_NO_SERIALIZE or for heaps created with a fixed size. The LFH also cannot be enabled if you are using the heap debugging tools in Debugging Tools for Windows or Microsoft Application Verifier .
When a process is run under any debugger, certain heap debug options are automatically enabled for all heaps in the process. These heap debug options prevent the use of the LFH. To enable the low-fragmentation heap when running under a debugger, set the _NO_DEBUG_HEAP environment variable to 1.
HeapEnableTerminationOnCorruption
1Enables the terminate-on-corruption feature. If the heap manager detects an error in any heap used by the process, it calls the Windows Error Reporting service and terminates the process.
After a process enables this feature, it cannot be disabled.
Windows Server 2003 and Windows XP/2000: This value is not supported until Windows Vista and Windows XP with SP3. The function succeeds but the HeapEnableTerminationOnCorruption value is ignored.

HeapInformation [in]
The heap information buffer. The format of this data depends on the value of the HeapInformationClass parameter.
If the HeapInformationClass parameter is HeapCompatibilityInformation, the HeapInformation parameter is a pointer to a ULONG variable.
If the HeapInformationClass parameter is HeapEnableTerminationOnCorruption, the HeapInformation parameter should be NULL and HeapInformationLength should be 0
HeapInformationLength [in]
The size of the HeapInformation buffer, in bytes.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError .
Remarks
To retrieve the current settings for the heap, use the HeapQueryInformation function.
Setting the HeapEnableTerminateOnCorruption option is strongly recommended because it reduces an application's exposure to security exploits that take advantage of a corrupted heap.
To use this function on Windows 2000 with Service Pack 4 (SP4), install the hotfix described in KB 816542 .
Examples
The following example shows you how to enable the low-fragmentation heap.
#include
#include
#include
#define HEAP_LFH 2
int __cdecl _tmain()
{
BOOL bResult;
HANDLE hHeap;
ULONG HeapInformation;
//
// Note: The HeapSetInformation function is available on Windows 2000 with SP4
// only if hotfix KB 816542 is installed. To run this example on Windows 2000,
// use GetProcAddress to get a pointer to the function if available.
//
//
// Enable heap terminate-on-corruption.
// A correct application can continue to run even if this call fails,
// so it is safe to ignore the return value and call the function as follows:
// (void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
// If the application requires heap terminate-on-corruption to be enabled,
// check the return value and exit on failure as shown in this example.
//
bResult = HeapSetInformation(NULL,
HeapEnableTerminationOnCorruption,
NULL,
0);
if (bResult != FALSE) {
_tprintf(TEXT("Heap terminate-on-corruption has been enabled.\\n"));
}
else {
_tprintf(TEXT("Failed to enable heap terminate-on-corruption with LastError %d.\\n"),
GetLastError());
return 1;
}
//
// Create a new heap with default parameters.
//
hHeap = HeapCreate(0, 0, 0);
if (hHeap == NULL) {
_tprintf(TEXT("Failed to create a new heap with LastError %d.\\n"),
GetLastError());
return 1;
}
//
// Enable the low-fragmenation heap (LFH). Starting with Windows Vista,
// the LFH is enabled by default but this call does not cause an error.
//
HeapInformation = HEAP_LFH;
bResult = HeapSetInformation(hHeap,
HeapCompatibilityInformation,
&HeapInformation,
sizeof(HeapInformation));
if (bResult != FALSE) {
_tprintf(TEXT("The low-fragmentation heap has been enabled.\\n"));
}
else {
_tprintf(TEXT("Failed to enable the low-fragmentation heap with LastError %d.\\n"),
GetLastError());
return 1;
}
return 0;
}
Requirements
Minimum supported clientWindows XP, Windows 2000 Professional with SP4
Minimum supported serverWindows Server 2003
VersionKB 816542 on Windows 2000 with SP4
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
GetProcessHeap
Heap Functions
HeapCreate
HeapQueryInformation
Memory Management Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366705(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:24:30