AutoHotkey Community

It is currently May 27th, 2012, 3:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: November 2nd, 2005, 11:08 am 
Offline

Joined: October 4th, 2005, 9:36 am
Posts: 11
Hi there,

such a function would be very nice to have as I want to read the real memory size out of my system:

http://www.autoitscript.com/autoit3/docs/functions/MemGetStats.htm

Maybe this is for help for the programmers of AutoHotkey:

http://vb-tec.de/memstat.htm

(OK, it's just VB, but it is an example how to use the C-API calls to get the stuff).

Greetings, Thomas


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 2nd, 2005, 12:48 pm 
Offline

Joined: May 26th, 2004, 12:20 pm
Posts: 61
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 2nd, 2005, 12:56 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 2nd, 2005, 1:02 pm 
Offline

Joined: May 26th, 2004, 12:20 pm
Posts: 61
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 2nd, 2005, 1:23 pm 
Offline

Joined: October 4th, 2005, 9:36 am
Posts: 11
Ah, thank you very much, this was really fast ;-)

Greetings, Thomas


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group