I have looked all over the place and can't find how to call GetProcessMemoryInfo using AHK.
the MSDN link is GetProcessMemoryInfo
That whole c++ syntax is such greek to me, I can't even begin to comprhend it enough to make it work in AHK.
I would like to find out how much memory a process is consuming, and from the looks of it that is the function to do it.
[ Moderator!: MSDN link fixed ]
How do you call this function using dllcall?
Started by
jd
, Sep 30 2008 06:48 PM
2 replies to this topic
#1
-
Posted 30 September 2008 - 06:48 PM
Here's a wrapper function:
Msgbox % GetProcessMemoryInfo( "firefox.exe" ) GetProcessMemoryInfo( pname ) { Process, Exist, %pname% pid := Errorlevel ; get process handle hProcess := DllCall( "OpenProcess", UInt, 0x10|0x400, Int, false, UInt, pid ) ; get memory info VarSetCapacity( memCounters, 40, 0 ) DllCall( "psapi.dll\GetProcessMemoryInfo", UInt, hProcess, UInt, &memCounters, UInt, 40 ) DllCall( "CloseHandle", UInt, hProcess ) list = cb,PageFaultCount,PeakWorkingSetSize,WorkingSetSize,QuotaPeakPagedPoolUsage ,QuotaPagedPoolUsage,QuotaPeakNonPagedPoolUsage,QuotaNonPagedPoolUsage ,PagefileUsage,PeakPagefileUsage /* cb := NumGet( memCounters, 0, "UInt" ) PageFaultCount := NumGet( memCounters, 4, "UInt" ) PeakWorkingSetSize := NumGet( memCounters, 8, "UInt" ) WorkingSetSize := NumGet( memCounters, 12, "UInt" ) QuotaPeakPagedPoolUsage := NumGet( memCounters, 16, "UInt" ) QuotaPagedPoolUsage := NumGet( memCounters, 20, "UInt" ) QuotaPeakNonPagedPoolUsage := NumGet( memCounters, 24, "UInt" ) QuotaNonPagedPoolUsage := NumGet( memCounters, 28, "UInt" ) PagefileUsage := NumGet( memCounters, 32, "UInt" ) PeakPagefileUsage := NumGet( memCounters, 36, "UInt" ) */ n=0 Loop, Parse, list, `, { n+=4 SetFormat, Float, 0.0 ; round up K this := A_Loopfield this := NumGet( memCounters, (A_Index = 1 ? 0 : n-4), "UInt") / 1024 ; omit cb If A_Index != 1 info .= A_Loopfield . ": " . this . " K" . ( A_Loopfield != "" ? "`n" : "" ) } ; Return "[" . pid . "] " . pname . "`n`n" . info ; for everything Return WorkingSetSize := NumGet( memCounters, 12, "UInt" ) / 1024 . " K" ; what Task Manager shows }
#2
-
Posted 01 October 2008 - 03:27 PM
"Anything worth doing is worth doing slowly." - Mae West
Serenity your function returns wrong size, it's about half size of the process memory usage.
Any idea why ?
#3
-
Posted 26 April 2013 - 07:42 AM