内存信息(300分)

  • 主题发起人 主题发起人 owow
  • 开始时间 开始时间
O

owow

Unregistered / Unconfirmed
GUEST, unregistred user!
glogalmemortstatus函数
 
The GlobalMemoryStatus function retrieves information about current available memory. The function returns information about both physical and virtual memory. This function supersedes the GetFreeSpace function.

VOID GlobalMemoryStatus(

LPMEMORYSTATUS lpBuffer // pointer to the memory status structure
);


Parameters

lpBuffer

Points to a MEMORYSTATUS structure in which information about current memory availability is returned. Before calling this function, the calling process should set the dwLength member of this structure.



Return Values

This function does not return a value.

Remarks

An application can use the GlobalMemoryStatus function to determine how much memory it can allocate without severely impacting other applications.
The information returned is volatile, and there is no guarantee that two sequential calls to this function will return the same information.
 
内存知多少
下面介绍一种方法可以决定系统内存的多少、使用状态等信息。更重要的是,应用程序可以利用这项技术来决定客户机的可用内存的大小,利用这些信息,应用程序可以动态地优化程序的性能。例如,如果有足够的内存可以利用双缓存优化位图的操作。

利用Windows API函数GlobalMemoryStatus可以完成上述功能。GlobalMemoryStatus接收一个类型为TMemoryStatus的变参,通过这个参数就可以获得Windows当前的内存状态。TMemoryStatus的结构如下:

typedef struct _MEMORYSTATUS { // mst

DWORD dwLength; // sizeof(MEMORYSTATUS),该记录结构的大小

DWORD dwMemoryLoad; // 使用内存所占百分比

DWORD dwTotalPhys; // 物理内存的字节数

DWORD dwAvailPhys; // 自由物理可用内存字节数

DWORD dwTotalPageFile; // 页文件字节数

DWORD dwAvailPageFile; // 页文件的自由字节数

DWORD dwTotalVirtual; // 地址空间的用户字节数

DWORD dwAvailVirtual; // 自由用户字节数

} MEMORYSTATUS, *LPMEMORYSTATUS;

下面是使用GlobalMemoryStatus函数的一个例子:

procedure TForm1.Button1Click(Sender: TObject);

var

MemoryStatus: TMemoryStatus;

begin

MemoryStatus.dwLength := sizeof(MemoryStatus);

GlobalMemoryStatus(MemoryStatus);

Label1.Caption := 'Total Physical Memory: ' + IntToStr(MemoryStatus.dwTotalPhys);

end;

 
owow: 我想您是写错了吧!
应该是GlobalMemoryStatus 函数,在Win32帮助中这样解释的:

The GlobalMemoryStatus function retrieves information about current available
memory. The function returns information about both physical and virtual memory.
This function supersedes the GetFreeSpace function.

VOID GlobalMemoryStatus(
LPMEMORYSTATUS lpBuffer // pointer to the memory status structure
);


Parameters

lpBuffer

Points to a MEMORYSTATUS structure in which information about current memory
availability is returned. Before calling this function, the calling process
should set the dwLength member of this structure.



Return Values

This function does not return a value.

Remarks

An application can use the GlobalMemoryStatus function to determine how much
memory it can allocate without severely impacting other applications.
The information returned is volatile, and there is no guarantee that two
sequential calls to this function will return the same information.

如果您的E文还凑合的话,那我就不给您翻译了!
祝您好运!
 
好象是没什么用, 只是取回目前的内存(物理内存和虚拟内存)的状况, 给你的下一步作个参考
 
我想起来的唯一作用就是CorelDraw的一个什么功能, 一用到它之前先检查有多少内存可用,
太少就报出一个警告, 说最好有多少内存才可以很好的使用此功能.
 
后退
顶部