AU3获取本机内存大小?
AU3获取本机内存大小?求代码…… #include <GUIConstantsEx.au3>#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$hwnd = GUICreate("清理垃圾工具", 569, 383, 193, 125)
$Button1 = GUICtrlCreateButton("退 出", 464, 120, 89, 25, 0)
GUICtrlCreateLabel("内 存:", 180,206,100,25)
$mem=GUICtrlCreateLabel("", 240,206,50,100)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
info()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE,$Button1
Exit
EndSwitch
WEnd
Func info()
$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
$colMemory = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For $objectin $colMemory
GUICtrlSetData($mem,String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " MB")
Next
EndFunc 不用太准的话,_memglobal*好像就可以 MemGetStats()
具体用法看帮助文档,但取得的内存大小和楼上的代码取的大小有差别,不知道原因
If _MemStats() Then
;Next
Else
Exit ;程序工作内存 大于 物理剩余内存 时,退出程序!
EndIf
;------------------------------------/
;_MemStats()
Func _MemStats()
Local $Mem1 = ProcessGetStats(), $Mem2 = MemGetStats()
If Not @Compiled Then
ConsoleWrite(@LF & "程序内存占用:" & Int($Mem1 / 1000 / 1000) & "M")
ConsoleWrite(@LF & "物理内存可用:" & Int($Mem2 / 1000) & "M" & @LF)
EndIf
If Int($Mem2 / 1000) > Int($Mem1 / 1000 / 1000) Then
Return True
Else
Return False
EndIf
;~ If Not @Compiled Then Return SetError(1,0,"")
;~
;~ Local $Mem
;~
;~ $Mem = ProcessGetStats()
;~ ConsoleWrite( _
;~ @LF & "程序内存占用:" & Int($Mem / 1000 / 1000) & "M" & _
;~ @LF & "程序峰值内存:" & Int($Mem / 1000 / 1000) & "M" & "" _
;~ )
;~ $Mem = MemGetStats()
;~ ConsoleWrite( _
;~ @LF & "内存使用率:" & Int($Mem) & "%" & _
;~ @LF & "物理内存总数:" & Int($Mem / 1000) & "M" & _
;~ @LF & "物理内存可用:" & Int($Mem / 1000) & "M" & _
;~ @LF & "页面文件大小:" & Int($Mem / 1000) & "M" & _
;~ @LF & "可用页面文件大小:" & Int($Mem / 1000) & "M" & _
;~ @LF & "虚拟内存大小:" & Int($Mem / 1000) & "M" & _
;~ @LF & "可用虚拟内存大小:" & Int($Mem / 1000) & "M" & @LF _
;~ )
EndFunc ;==>_MemStats
;------------------------------------/
建议楼主参考此文章:
http://www.autoitx.com/thread-19175-1-1.html
页:
[1]