Shoutbox

GlobalMemoryStatusEx function??? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: GlobalMemoryStatusEx function??? (/showthread.php?tid=99619)

GlobalMemoryStatusEx function??? by agustin029 on 09-14-2012 at 01:22 AM

how I can use this function in javascript??


http://msdn.microsoft.com/en-us/library/windows/d...6589(v=vs.85).aspx

code:
mem32 = Interop.Call('kernel32', 'GlobalMemoryStatusEx', 'MEMORYSTATUSEX');
var string_memory = mem32.dwMemoryLoad; ??


RE: GlobalMemoryStatusEx function??? by Spunky on 09-14-2012 at 07:39 AM

MEMORYSTATUSEX isn't a String, it's a structure. The documentation for it can be found here

You will need to use Data Blocs to emulate the structure and then you can read information out with functions like

Javascript code:
myDataBloc.readDWORD(0);

as described in the documentation for MP! scripting
RE: GlobalMemoryStatusEx function??? by matty on 09-14-2012 at 12:13 PM

Javascript code:
/*
    typedef struct _MEMORYSTATUSEX {
      DWORD     dwLength;                       0
      DWORD     dwMemoryLoad;                   4
      DWORDLONG ullTotalPhys;                   8
      DWORDLONG ullAvailPhys;                   16
      DWORDLONG ullTotalPageFile;               24
      DWORDLONG ullAvailPageFile;               32
      DWORDLONG ullTotalVirtual;                40
      DWORDLONG ullAvailVirtual;                48
      DWORDLONG ullAvailExtendedVirtual;        56
    } MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
*/

var DIV = 1024;
var _MEMORYSTATUSEX = Interop.Allocate(64);
    _MEMORYSTATUSEX.WriteDWORD(0, _MEMORYSTATUSEX.Size);
Debut.Trace('RetVal: '+Interop.Call('kernel32', 'GlobalMemoryStatusEx', _MEMORYSTATUSEX));
 
Debug.Trace('There is '+_MEMORYSTATUSEX.ReadDWORD(4)+' percent of memory in use.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(8)/DIV+' total KB of physical memory.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(16)/DIV+' free  KB of physical memory.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(24)/DIV+' total KB of paging file.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(32)/DIV+' free  KB of paging file.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(40)/DIV+' total KB of virtual memory.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(48)/DIV+' free  KB of virtual memory.');
Debug.Trace('There are '+_MEMORYSTATUSEX.ReadDWORD(56)/DIV+' free  KB of extended memory.');


RE: GlobalMemoryStatusEx function??? by agustin029 on 09-15-2012 at 02:47 AM

i think i need to learn more =S, thank you very much!