[Fortran] 纯文本查看 复制代码
Program Main
use Kernel32
use ISO_C_Binding
Implicit None
type(T_MEMORYSTATUSEX) stMemStat
integer i
stMemStat%dwLength = c_sizeof(stMemStat)
i = GlobalMemoryStatusEx ( stMemStat )
write(*,*) "There is ",stMemStat%dwMemoryLoad,"% percent of memory in use."
write(*,*) "There are ",stMemStat%ullTotalPhys/1024," total KB of physical memory."
write(*,*) "There are ",stMemStat%ullAvailPhys/1024," free KB of physical memory."
write(*,*) "There are ",stMemStat%ullTotalPageFile/1024," total KB of paging file."
write(*,*) "There are ",stMemStat%ullAvailPageFile/1024," free KB of paging file."
write(*,*) "There are ",stMemStat%ullTotalVirtual/1024," total KB of virtual memory."
write(*,*) "There are ",stMemStat%ullAvailVirtual/1024," free KB of virtual memory."
write(*,*) "There are ",stMemStat%ullAvailExtendedVirtual/1024," free KB of extended memory."
End Program Main
[Fortran] 纯文本查看 复制代码
Program Main
use Kernel32
use ISO_C_Binding
Implicit None
TYPE My_MEMORYSTATUSEX
SEQUENCE
integer(DWORD) dwLength ! knowns DWORD
integer(DWORD) dwMemoryLoad ! knowns DWORD
integer(DWORDLONG) ullTotalPhys ! knowns DWORDLONG
integer(DWORDLONG) ullAvailPhys ! knowns DWORDLONG
integer(DWORDLONG) ullTotalPageFile ! knowns DWORDLONG
integer(DWORDLONG) ullAvailPageFile ! knowns DWORDLONG
integer(DWORDLONG) ullTotalVirtual ! knowns DWORDLONG
integer(DWORDLONG) ullAvailVirtual ! knowns DWORDLONG
integer(DWORDLONG) ullAvailExtendedVirtual ! knowns DWORDLONG
END TYPE
type(T_MEMORYSTATUSEX) stMemStat
type(My_MEMORYSTATUSEX) stMyMemStat
integer i
stMemStat%dwLength = c_sizeof(stMemStat)
i = GlobalMemoryStatusEx ( stMemStat )
stMyMemStat = transfer( stMemStat , stMyMemStat )
write(*,*) "There is ",stMyMemStat%dwMemoryLoad,"% percent of memory in use."!//内存使用百分比
write(*,*) "There are ",stMyMemStat%ullTotalPhys/1024," total KB of physical memory."!//物理内存总量
write(*,*) "There are ",stMyMemStat%ullAvailPhys/1024," free KB of physical memory."!//物理内存可用量
write(*,*) "There are ",stMyMemStat%ullTotalPageFile/1024," total KB of paging file."!//虚拟内存(页面文件)总量
write(*,*) "There are ",stMyMemStat%ullAvailPageFile/1024," free KB of paging file."!//虚拟内存(页面文件)可用量
write(*,*) "There are ",stMyMemStat%ullTotalVirtual/1024," total KB of virtual memory."!//虚拟地址总量,32位固定为2GB
write(*,*) "There are ",stMyMemStat%ullAvailVirtual/1024," free KB of virtual memory."!//虚拟地址可用量(可以认为这个代表可用值)
write(*,*) "There are ",stMyMemStat%ullAvailExtendedVirtual/1024," free KB of extended memory."
End Program Main