术语 | globalmemorystatusex |
释义 | GlobalMemoryStatusEx 语法: C++ BOOL WINAPI GlobalMemoryStatusEx( __inout LPMEMORYSTATUSEX lpBuffer ); GlobalMemoryStatusEx函数 检索信息系统的物理和虚拟内存的当前使用情况。 参数 lpBuffer [ in , out ] 一个MEMORYSTATUSEX结构的接收关于当前内存的可用性信息的指针。 返回值 如果函数成功,返回值为非零。 如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。 备注 您可以使用GlobalMemoryStatusEx函数,以确定有多少内存,应用程序可以分配不严重影响其他应用程序。 GlobalMemoryStatusEx函数所返回的信息是不稳定的。也不能保证这两个函数顺序调用将返回相同的信息。 对在lpBuffer MEMORYSTATUSEX结构的ullAvailPhys成员包括所有的NUMA节点的内存。 实例 下面一个代码显示GlobalMemoryStatusEx函数的简单使用。 // Sample output: // There is 51 percent of memory in use. // There are 2029968 total Kbytes of physical memory. // There are 987388 free Kbytes of physical memory. // There are 3884620 total Kbytes of paging file. // There are 2799776 free Kbytes of paging file. // There are 2097024 total Kbytes of virtual memory. // There are 2084876 free Kbytes of virtual memory. // There are 0 free Kbytes of extended memory. #include #include // Use to convert bytes to KB #define DIV 1024 // Specify the width of the field in which to print the numbers. // The asterisk in the format specifier "%*I64d" takes an integer // argument and uses it to pad and right justify the number. #define WIDTH 7 void main(int argc, char *argv[]) { MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); GlobalMemoryStatusEx (&statex); printf ("There is %*ld percent of memory in use.\\n", WIDTH, statex.dwMemoryLoad); printf ("There are %*I64d total Kbytes of physical memory.\\n", WIDTH, statex.ullTotalPhys/DIV); printf ("There are %*I64d free Kbytes of physical memory.\\n", WIDTH, statex.ullAvailPhys/DIV); printf ("There are %*I64d total Kbytes of paging file.\\n", WIDTH, statex.ullTotalPageFile/DIV); printf ("There are %*I64d free Kbytes of paging file.\\n", WIDTH, statex.ullAvailPageFile/DIV); printf ("There are %*I64d total Kbytes of virtual memory.\\n", WIDTH, statex.ullTotalVirtual/DIV); printf ("There are %*I64d free Kbytes of virtual memory.\\n", WIDTH, statex.ullAvailVirtual/DIV); // Show the amount of extended memory available. printf ("There are %*I64d free Kbytes of extended memory.\\n", WIDTH, statex.ullAvailExtendedVirtual/DIV); } 要求: 最低支持:client-Windows 2000专业版 最低支持server-Windows 2000服务器 HeaderWinbase.h(头文件:winuser.h) LibraryKernel32.lib DLLKernel32.dll 参见 内存管理功能 内存性能信息 MEMORYSTATUSEX 虚拟地址空间和物理存储 如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com) 生成日期:2009年8月27日 ==英文原文==GlobalMemoryStatusEx Function Retrieves information about the system's current usage of both physical and virtual memory. Syntax C++ BOOL WINAPI GlobalMemoryStatusEx( __inout LPMEMORYSTATUSEX lpBuffer ); Parameters lpBuffer [in, out] A pointer to a MEMORYSTATUSEX structure that receives information about current memory availability. Return Value If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError . Remarks You can use the GlobalMemoryStatusEx function to determine how much memory your application can allocate without severely impacting other applications. The information returned by the GlobalMemoryStatusEx function is volatile. There is no guarantee that two sequential calls to this function will return the same information. The ullAvailPhys member of the MEMORYSTATUSEX structure at lpBuffer includes memory for all NUMA nodes. Examples The following code shows a simple use of the GlobalMemoryStatusEx function. // Sample output: // There is 51 percent of memory in use. // There are 2029968 total Kbytes of physical memory. // There are 987388 free Kbytes of physical memory. // There are 3884620 total Kbytes of paging file. // There are 2799776 free Kbytes of paging file. // There are 2097024 total Kbytes of virtual memory. // There are 2084876 free Kbytes of virtual memory. // There are 0 free Kbytes of extended memory. #include #include // Use to convert bytes to KB #define DIV 1024 // Specify the width of the field in which to print the numbers. // The asterisk in the format specifier "%*I64d" takes an integer // argument and uses it to pad and right justify the number. #define WIDTH 7 void main(int argc, char *argv[]) { MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); GlobalMemoryStatusEx (&statex); printf ("There is %*ld percent of memory in use.\\n", WIDTH, statex.dwMemoryLoad); printf ("There are %*I64d total Kbytes of physical memory.\\n", WIDTH, statex.ullTotalPhys/DIV); printf ("There are %*I64d free Kbytes of physical memory.\\n", WIDTH, statex.ullAvailPhys/DIV); printf ("There are %*I64d total Kbytes of paging file.\\n", WIDTH, statex.ullTotalPageFile/DIV); printf ("There are %*I64d free Kbytes of paging file.\\n", WIDTH, statex.ullAvailPageFile/DIV); printf ("There are %*I64d total Kbytes of virtual memory.\\n", WIDTH, statex.ullTotalVirtual/DIV); printf ("There are %*I64d free Kbytes of virtual memory.\\n", WIDTH, statex.ullAvailVirtual/DIV); // Show the amount of extended memory available. printf ("There are %*I64d free Kbytes of extended memory.\\n", WIDTH, statex.ullAvailExtendedVirtual/DIV); } Requirements Minimum supported clientWindows 2000 Professional Minimum supported serverWindows 2000 Server HeaderWinbase.h (include Windows.h) LibraryKernel32.lib DLLKernel32.dll See Also Memory Management Functions Memory Performance Information MEMORYSTATUSEX Virtual Address Space and Physical Storage Send comments about this topic to Microsoft Build date: 8/27/2009 ==原始网址==http://msdn.microsoft.com/en-us/library/aa366589(VS.85).aspx\n |
随便看 |
|
windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。