Query power consumption

M

Marc Gravell

I would like to query (where possible) the power consumption of the local
PC. Obviously this requires hardware support, but similar apps leads me to
believe that this is possible. I looked at wmi (below) but this is empty on
my XP machines... any other ideas on how to get this data? If it is even
possible...

TIA,

Marc

static void Main() {
using (ManagementObjectSearcher query = new
ManagementObjectSearcher("SELECT * FROM Win32_CurrentProbe"))
using (ManagementObjectCollection results = query.Get()) {
Console.WriteLine("{0} current feed(s)", results.Count);
foreach (ManagementObject mo in results) {
Console.WriteLine("{0}: {1}", mo["Caption"],
mo["CurrentReading"]);
}
}
using (ManagementObjectSearcher query = new
ManagementObjectSearcher("SELECT * FROM Win32_VoltageProbe"))
using (ManagementObjectCollection results = query.Get()) {
Console.WriteLine("{0} voltage feed(s)", results.Count);
foreach (ManagementObject mo in results) {
Console.WriteLine("{0}: {1}", mo["Caption"],
mo["CurrentReading"]);
}
}
}
 
C

Chan Ming Man

Normally in WMI you need to specify the machine name but I did not see you
have it.

chanmm
 
W

Willy Denoyette [MVP]

Marc Gravell said:
I would like to query (where possible) the power consumption of the local PC. Obviously
this requires hardware support, but similar apps leads me to believe that this is possible.
I looked at wmi (below) but this is empty on my XP machines... any other ideas on how to
get this data? If it is even possible...

TIA,

Marc

static void Main() {
using (ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM
Win32_CurrentProbe"))
using (ManagementObjectCollection results = query.Get()) {
Console.WriteLine("{0} current feed(s)", results.Count);
foreach (ManagementObject mo in results) {
Console.WriteLine("{0}: {1}", mo["Caption"], mo["CurrentReading"]);
}
}
using (ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM
Win32_VoltageProbe"))
using (ManagementObjectCollection results = query.Get()) {
Console.WriteLine("{0} voltage feed(s)", results.Count);
foreach (ManagementObject mo in results) {
Console.WriteLine("{0}: {1}", mo["Caption"], mo["CurrentReading"]);
}
}
}


You need the necessary HW (current and voltage probes) and driver support, don't assume
every WMI class to be backed by this kind of support. Only some high-end server systems have
necessary HW support, but most vendors don't care to write the necessary WMI providers and
opt for a proprietary solution.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top