开发者

C# using WMI to query Win32_Fan class and fan speed return null?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜