Quantcast

Maximum PC

It is currently Fri Aug 29, 2014 6:49 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: GlobalMemoryStatusEx
PostPosted: Thu Sep 25, 2008 7:18 pm 
I'd rather be modding!
I'd rather be modding!
User avatar

Joined: Fri Jun 25, 2004 3:47 pm
Posts: 3731
Location: Las Vegas
Ok,

So why does this work:
Code:
from ctypes import *
from ctypes.wintypes import *
from sys import *



class MEMORYSTATUS(Structure):
    _fields_ = [
        ('dwLength', DWORD),
        ('dwMemoryLoad', DWORD),
        ('dwTotalPhys', DWORD),
        ('dwAvailPhys', DWORD),
        ('dwTotalPageFile', DWORD),
        ('dwAvailPageFile', DWORD),
        ('dwTotalVirtual', DWORD),
        ('dwAvailVirtual', DWORD),
    ]

def winmem():
    x = MEMORYSTATUS()
    windll.kernel32.GlobalMemoryStatus(byref(x))
    return x

m=winmem()

load = m.dwMemoryLoad
vram = m.dwAvailVirtual
vtot = m.dwTotalVirtual
pageav = m.dwAvailPageFile
pagetot = m.dwTotalPageFile
ramtot = m.dwTotalPhys
ramav = m.dwAvailPhys
bit = m.dwLength

print bit,vram,vtot,ramtot


But this doesn't:
Code:
from ctypes import *
from ctypes.wintypes import *
from sys import *



class MEMORYSTATUSEX(Structure):
    _fields_ = [
        ('dwLength', DWORD),
        ('dwMemoryLoad', DWORD),
        ('ullTotalPhys', ULONG),
        ('ullAvailPhys', ULONG),
        ('ullTotalPageFile', ULONG),
        ('ullAvailPageFile', ULONG),
        ('ullTotalVirtual', ULONG),
        ('ullAvailVirtual', ULONG),
    ]

def winmem():
    x = MEMORYSTATUSEX()
    windll.kernel32.GlobalMemoryStatusEx(byref(x))
    return x

m=winmem()

load = m.dwMemoryLoad
vram = m.ullAvailVirtual
vtot = m.ullTotalVirtual
pageav = m.ullAvailPageFile
pagetot = m.ullTotalPageFile
ramtot = m.ullTotalPhys
ramav = m.ullAvailPhys
bit = m.dwLength

print bit,vram,vtot,ramtot


The EX version is the new one and replaces the other.

When I say it doesn't work, I mean the first one reports the proper memory (within it's limits), but the second only reports zero's for everything

Any ideas?


Top
  Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2008 11:41 am 
Team Member Top 100
Team Member Top 100

Joined: Fri Sep 17, 2004 5:35 pm
Posts: 1176
Look at the MSDN page: http://msdn.microsoft.com/en-us/library/aa366589(VS.85).aspx
Also, pay really close attention to the types used in the structure (DWORDLONG means 'unsigned __int64' or 'unsigned long long', i.e. an unsigned 64-bit int)

Also, you should call GetLastError() and see what the error was


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot 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:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group