How to get Windows physical RAM using python?
tim.golden at viacom-outdoor.co.uk
Thu Jul 31 10:28:25 CEST 2003
BranimirPetrovic at yahoo.com (Branimir Petrovic) wrote in message news:<b11d1191.0307301601.67450ca3 at posting.google.com>...
> "Martin v. Löwis" <martin at v.loewis.de> wrote in message news:<bg920a$9pt$05$1 at news.t-online.com>...
> > Python can't get you Windows physical RAM. You have to order RAM
> > from a manufacturer or reseller if Windows needs more RAM :-)
> > Regards,
> > Martin
> "Easy" way to get to physical RAM on Windows is via WMI objects.
And here's how you'd do it in Python:
1) Get WMI module from http://tgolden.sc.sabren.com/wmi.html
2) Do something like this:
computer = wmi.WMI ()
for i in computer.Win32_ComputerSystem ():
print i.Caption, "has", i.TotalPhysicalMemory, "bytes of memory"
Obviously you can fiddle around with Megabytes and Gigabytes and so on
if you need to. The loop is a slight hack: you obviously only have one
computer system, but this interface to WMI always returns a list
(albeit of one value).
More information about the Python-list