How to get Windows physical RAM using python?
Tim Golden
tim.golden at viacom-outdoor.co.uk
Thu Jul 31 04:28:25 EDT 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:
<code>
import wmi
computer = wmi.WMI ()
for i in computer.Win32_ComputerSystem ():
print i.Caption, "has", i.TotalPhysicalMemory, "bytes of memory"
</code>
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).
HTH
TJG
More information about the Python-list
mailing list