VB中的API声明:
Public Declare Sub GlobalMemoryStatus Lib "kernel32" _
(lpBuffer As MemoryStatus)Public memInfo As MemoryStatus数据结构为:
Public Type MemoryStatus
dwLength As Long
dwMemoryLoad As Long
dwTotalPhys As Long
dwAvailPhys As Long
dwTotalPageFile As Long
dwAvailPageFile As Long
dwTotalVirtual As Long
dwAvailVirtual As Long
End Type'这个数据结构在头文件“WinBase.h”中有对应的C函数定义:
'typedef struct _MEMORYSTATUS {
' DWORD dwLength;
' DWORD dwMemoryLoad;
' SIZE_T dwTotalPhys;
' SIZE_T dwAvailPhys;
' SIZE_T dwTotalPageFile;
' SIZE_T dwAvailPageFile;
' SIZE_T dwTotalVirtual;
' SIZE_T dwAvailVirtual;
'} MEMORYSTATUS, *LPMEMORYSTATUS;请问,那本参考书上有对这个API数据结构中定义的各个变量的详细解释
Public Declare Sub GlobalMemoryStatus Lib "kernel32" _
(lpBuffer As MemoryStatus)Public memInfo As MemoryStatus数据结构为:
Public Type MemoryStatus
dwLength As Long
dwMemoryLoad As Long
dwTotalPhys As Long
dwAvailPhys As Long
dwTotalPageFile As Long
dwAvailPageFile As Long
dwTotalVirtual As Long
dwAvailVirtual As Long
End Type'这个数据结构在头文件“WinBase.h”中有对应的C函数定义:
'typedef struct _MEMORYSTATUS {
' DWORD dwLength;
' DWORD dwMemoryLoad;
' SIZE_T dwTotalPhys;
' SIZE_T dwAvailPhys;
' SIZE_T dwTotalPageFile;
' SIZE_T dwAvailPageFile;
' SIZE_T dwTotalVirtual;
' SIZE_T dwAvailVirtual;
'} MEMORYSTATUS, *LPMEMORYSTATUS;请问,那本参考书上有对这个API数据结构中定义的各个变量的详细解释
Type MEMORYSTATUS '指向内存的结构体
dwLength As Long 'MEMORYSTATUS的大小
dwMemoryLoad As Long '内存利用百分比
dwTotalPhys As Long '物理内存大小
dwAvailPhys As Long '可用物理内存的大小
dwTotalPageFile As Long '页面文件的大小
dwAvailPageFile As Long '可用页面文件的大小
dwTotalVirtual As Long '虚拟内存大小 ??
dwAvailVirtual As Long '可用虚拟内存大小 ??
End Type
具体实现内存如下:
Dim mem As MEMORYSTATUS
GlobalMemoryStatus mem
MemSize.Caption = "物理内存:" & CInt(mem.dwTotalPhys / 1024 / 1024) & "M"
MemSize.Caption = MemSize.Caption & " 可用物理内存: " & CInt(mem.dwAvailPhys / 1024 / 1024) & "M" & vbCrLf
MemSize.Caption = MemSize.Caption & vbCrLf
' MemSize.Caption = MemSize.Caption & "虚拟内存大小: " & CInt(mem.dwTotalPageFile / 1024 / 1024) &
' "M"
Members
dwLength
The size in bytes of the MEMORYSTATUS data structure. You do not need to set this member before calling the GlobalMemoryStatus function; the function sets it.
dwMemoryLoad
Specifies a number between 0 and 100 that gives a general idea of current memory utilization, in which 0 indicates no memory use and 100 indicates full memory use.
dwTotalPhys
Indicates the total number of bytes of physical memory.
dwAvailPhys
Indicates the number of bytes of physical memory available.
dwTotalPageFile
Indicates the total number of bytes that can be stored in the paging file. Note that this number does not represent the actual physical size of the paging file on disk.
dwAvailPageFile
Indicates the number of bytes available in the paging file.
dwTotalVirtual
Indicates the total number of bytes that can be described in the user mode portion of the virtual address space of the calling process.
dwAvailVirtual
Indicates the number of bytes of unreserved and uncommitted memory in the user mode portion of the virtual address space of the calling process.