Query power consumption

  • Thread starter Thread starter Marc Gravell
  • Start date Start date
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"]);
}
}
}
 
Normally in WMI you need to specify the machine name but I did not see you
have it.

chanmm
 
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.
 
Back
Top