 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Cerdan
Joined: 04 Oct 2005 Posts: 11
|
|
| Back to top |
|
 |
antonyb
Joined: 26 May 2004 Posts: 61
|
Posted: Wed Nov 02, 2005 12:48 pm Post subject: |
|
|
With thanks to Shimanov and his ReadInteger function!
| Code: | statString:=MemGetStats()
StringSplit, stats, statString, |
FileAppend, Memory Load: %stats1%`n, *
FileAppend, Total Physical Ram: %stats2%k`n, *
FileAppend, Available Physical Ram: %stats3%k`n, *
FileAppend, Total Pagefile: %stats4%k`n, *
FileAppend, Available Pagefile: %stats5%k`n, *
FileAppend, Total Virtual: %stats6%k`n, *
FileAppend, Available Virtual: %stats7%k`n, *
MemGetStats()
{
; See:
; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memorystatus_str.asp
VarSetCapacity(memorystatus, 4+4+4+4+4+4+4+4)
success := DllCall("kernel32.dll\GlobalMemoryStatus", "uint", &memorystatus)
stats := ReadInteger(&memorystatus,4,4, false) ; Memory Load (Percentage of memory in use)
stats := stats "|" Round(ReadInteger(&memorystatus,8,4, false)/1024) ; Total Physical Ram
stats := stats "|" Round(ReadInteger(&memorystatus,12,4, false)/1024) ; Available Physical Ram
stats := stats "|" Round(ReadInteger(&memorystatus,16,4, false)/1024) ; Total Pagefile
stats := stats "|" Round(ReadInteger(&memorystatus,20,4, false)/1024) ; Available Pagefile
stats := stats "|" Round(ReadInteger(&memorystatus,24,4, false)/1024) ; Total Virtual
stats := stats "|" Round(ReadInteger(&memorystatus,28,4, false)/1024) ; Available Virtual
return stats
}
ReadInteger( p_address, p_offset, p_size, p_hex=true )
{
value = 0
old_FormatInteger := a_FormatInteger
if ( p_hex )
SetFormat, integer, hex
else
SetFormat, integer, dec
loop, %p_size%
value := value+( *( ( p_address+p_offset )+( a_Index-1 ) ) << ( 8* ( a_Index-1 ) ) )
SetFormat, integer, %old_FormatInteger%
return, value
} |
Ant |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Wed Nov 02, 2005 12:56 pm Post subject: |
|
|
| antonyb wrote: | | With thanks to Shimanov and his ReadInteger function! |
Cool!
If I were just a bit faster, I would have posted exactly (nearly so) the same code.
Oh well. |
|
| Back to top |
|
 |
antonyb
Joined: 26 May 2004 Posts: 61
|
Posted: Wed Nov 02, 2005 1:02 pm Post subject: |
|
|
Hah! Beat you to it!
I tried playing around with the NT performance counters too (here) but got nowhere fast. So if you get bored....
Ant. |
|
| Back to top |
|
 |
Cerdan
Joined: 04 Oct 2005 Posts: 11
|
Posted: Wed Nov 02, 2005 1:23 pm Post subject: |
|
|
Ah, thank you very much, this was really fast
Greetings, Thomas |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|