读书人

怎么查看函数的用法(在Delphi的帮助文

发布时间: 2012-03-20 14:01:11 作者: rapoo

如何查看函数的用法(在Delphi的帮助文件)
比如我想查看GlobalMemoryStatus函数的用法啊什么的,在索引里搜过“GlobalMemoryStatus”了,但是都没有这个关键字。要怎么看呢?可不可以详细地说说呢?谢谢了:)

[解决办法]
这个在Help-> Window SDK查看!
[解决办法]
Delphi主菜单的Help菜单中有一个菜单项[Windows SDK]。
[解决办法]
Platform SDK: Memory Management
GlobalMemoryStatus

The GlobalMemoryStatus function obtains information about the system 's current usage of both physical and virtual memory.

To obtain information about the extended portion of the virtual address space, or if your application may run on computers with more than 4 GB of main memory, use the GlobalMemoryStatusEx function.


void GlobalMemoryStatus(
LPMEMORYSTATUS lpBuffer
);

Parameters
lpBuffer
[out] Pointer to a MEMORYSTATUS structure. The GlobalMemoryStatus function stores information about current memory availability into this structure.
Return Values
This function does not return a value.

Remarks
You can use the GlobalMemoryStatus function to determine how much memory your application can allocate without severely impacting other applications.

The information returned by the GlobalMemoryStatus function is volatile. There is no guarantee that two sequential calls to this function will return the same information.

On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information. Windows 2000 and later report a value of -1 to indicate an overflow. Earlier versions of Windows NT report a value that is the real amount of memory, modulo 4 GB. For this reason, use the GlobalMemoryStatusEx function instead.

On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the GlobalMemoryStatus function will always return 2 GB in the dwTotalPhys member of the MEMORYSTATUS structure. Similarly, if the total available memory is between 2 and 4 GB, the dwAvailPhys member of the MEMORYSTATUS structure will be rounded down to 2 GB. If the executable is linked using the /LARGEADDRESSWARE linker option, then the GlobalMemoryStatus function will return the correct amount of physical memory in both members.

Example Code
The following code shows a simple use of the GlobalMemoryStatus function.

// Sample output:
// c:\> global
// The MemoryStatus structure is 32 bytes long.
// It should be 32.
// 78 percent of memory is in use.
// There are 65076 total Kbytes of physical memory.
// There are 13756 free Kbytes of physical memory.
// There are 150960 total Kbytes of paging file.
// There are 87816 free Kbytes of paging file.
// There are 1fff80 total Kbytes of virtual memory.
// There are 1fe770 free Kbytes of virtual memory.

#include <windows.h>

// Use to change the divisor from Kb to Mb.

#define DIV 1024
// #define DIV 1

char *divisor = "K ";
// char *divisor = " ";

// Handle the width of the field in which to print numbers this way to
// make changes easier. The asterisk in the print format specifier
// "%*ld " takes an int from the argument list, and uses it to pad and
// right-justify the number being formatted.
#define WIDTH 7

void main(int argc, char *argv[])
{
MEMORYSTATUS stat;

GlobalMemoryStatus (&stat);

printf ( "The MemoryStatus structure is %ld bytes long.\n ",
stat.dwLength);
printf ( "It should be %d.\n ", sizeof (stat));
printf ( "%ld percent of memory is in use.\n ",


stat.dwMemoryLoad);
printf ( "There are %*ld total %sbytes of physical memory.\n ",
WIDTH, stat.dwTotalPhys/DIV, divisor);
printf ( "There are %*ld free %sbytes of physical memory.\n ",
WIDTH, stat.dwAvailPhys/DIV, divisor);
printf ( "There are %*ld total %sbytes of paging file.\n ",
WIDTH, stat.dwTotalPageFile/DIV, divisor);
printf ( "There are %*ld free %sbytes of paging file.\n ",
WIDTH, stat.dwAvailPageFile/DIV, divisor);
printf ( "There are %*lx total %sbytes of virtual memory.\n ",
WIDTH, stat.dwTotalVirtual/DIV, divisor);
printf ( "There are %*lx free %sbytes of virtual memory.\n ",
WIDTH, stat.dwAvailVirtual/DIV, divisor);
}
Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.


See Also
Memory Management Overview, Memory Management Functions, GlobalMemoryStatusEx, MEMORYSTATUS

Platform SDK Release: February 2003 What did you think of this topic?
Order a Platform SDK CD

读书人网 >.NET

热点推荐