here is code i used to query fan speed, but fan开发者_如何学Python speed always return null. Anyone know why?
public static void Win32_Fan() { SelectQuery query = new SelectQuery("Win32_Fan");
// Initialize an object searcher with this query
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(query);
// Get the resulting collection and loop through it
foreach (ManagementObject fan in searcher.Get())
{
Console.WriteLine("{0} = ActiveCooling {1}",fan["Name"], fan["ActiveCooling"]);
Console.WriteLine("DesiredSpeed = {0}", fan["DesiredSpeed"]);
}
}
What Hans is alluding to is the fact that WMI is very dependent on what the device driver supplies it. WMI defines a large assortment of classes with all kinds of useful properties, but most of those (related to hardware, anyway) need to be filled in by a driver. If the driver doesn't give WMI the information, then WMI can't give the information to you.
精彩评论