内存----------API
如何取本机的可用物理内存。 问题点数:20、回复次数:7Top
1 楼dialogs(满脸皱纹,身无分文)回复于 2001-06-06 21:06:00 得分 0
麻烦各位了.Top
2 楼dialogs(满脸皱纹,身无分文)回复于 2001-06-06 21:21:00 得分 0
如何取本机的可用物理内存Top
3 楼Asus(风月无边)回复于 2001-06-06 21:22:00 得分 10
VOID GlobalMemoryStatus(
LPMEMORYSTATUS lpBuffer // pointer to the memory status structure
);
//详细的看看帮助了
Top
4 楼hxshanji(洪兴山鸡)回复于 2001-06-06 21:23:00 得分 10
Unit
Windows.Pas
Syntax
GlobalMemoryStatus(
var lpBuffer: TMemoryStatus {a pointer to a TMemoryStatus structure}
); {this procedure does not return a value}
Description
This procedure fills a TMemoryStatus structure with information regarding physical and virtual memory. However, due to the nature of Window's memory management, two sequential calls to this function may yield different results.
Parameters
lpBuffer: A pointer to a TMemoryStatus structure that receives the information about physical and virtual memory status. The TMemoryStatus data structure is defined as:
TMemoryStatus = record
dwLength: DWORD; {the size of the structure in bytes}
dwMemoryLoad: DWORD; {estimated memory usage}
dwTotalPhys: DWORD; {the total amount of physical memory}
dwAvailPhys: DWORD; {the available amount of physical memory}
dwTotalPageFile: DWORD; {the total amount of swap file storage}
dwAvailPageFile: DWORD; {the available amount of swap file storage}
dwTotalVirtual: DWORD; {the total amount of virtual memory}
dwAvailVirtual: DWORD; {the available amount of virtual memory}
end;
dwLength: This member contains the size of the structure in bytes, and must be set to SizeOf(TMemoryStatus) before the call to GlobalMemoryStatus is made.
dwMemoryLoad: Contains a value between 0 and 100 indicating the approximate percentage of memory in use.
dwTotalPhys: Indicates the total amount of physical RAM in bytes.
dwAvailPhys: Indicates the total amount of available physical RAM in bytes.
dwTotalPageFile: Indicates the maximum amount of storage space in the swap file in bytes, including both used space and available space. This number does not represent the actual physical size of the swap file.
dwAvailPageFile: Indicates the total amount of available space in the swap file in bytes.
dwTotalVirtual: Indicates the total amount of virtual address space for the calling process in bytes.
dwAvailVirtual: Indicates the total amount of unreserved and uncommitted space in the virtual address space of the calling process in bytes.
The Tomes of Delphi 3: Win32 Core API Help File by Larry DiehlTop
5 楼hxshanji(洪兴山鸡)回复于 2001-06-06 21:23:00 得分 0
例子:
procedure TGlobalMemoryStatusForm.ButtonGlobalMemoryStatusClick(
Sender: TObject);
var
GlobalMemoryInfo : TMemoryStatus; // holds the global memory status information
begin
{set the size of the structure before the call.}
GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo);
{retrieve the global memory status...}
GlobalMemoryStatus(GlobalMemoryInfo);
{and display the information}
Label1.caption := 'Results of GlobalMemoryStatus:';
Label2.caption := 'Record structure size: '+IntToStr(
GlobalMemoryInfo.dwLength)+' bytes';
Label3.caption := 'Current memory load: '+IntToStr(
GlobalMemoryInfo.dwMemoryLoad)+'%';
Label4.caption := 'Total physical memory: '+Format('%.0n',[
GlobalMemoryInfo.dwTotalPhys/1])+' bytes';
Label5.caption := 'Total available physical memory: '+Format('%.0n',[
GlobalMemoryInfo.dwAvailPhys/1])+' bytes';
Label6.caption := 'Total paging file size: '+Format('%.0n',[
GlobalMemoryInfo.dwTotalPageFile/1])+' bytes';
Label7.Caption := 'Total available paging file memory: '+Format('%.0n',[
GlobalMemoryInfo.dwAvailPageFile/1])+' bytes';
Label8.caption := 'Total virtual memory: '+Format('%.0n',[
GlobalMemoryInfo.dwTotalVirtual/1])+' bytes';
Label9.caption := 'Total available virtual memory: '+Format('%.0n',[
GlobalMemoryInfo.dwAvailVirtual/1])+' bytes';
end;
Top
6 楼Musicwind(Musicwind)回复于 2001-06-06 21:24:00 得分 0
参看Delphi自带的例子程序,里面有.Top
7 楼dialogs(满脸皱纹,身无分文)回复于 2001-06-06 22:00:00 得分 0
thank you
Top




