开发者

How can programmatically check which version of the WMI is installed

How can programmatically check which version of the WMI (Win开发者_开发知识库dows Management Instrumentation) is installed using delphi or C#?


Try:

using System.Management;

ManagementObjectSearcher query = new
    ManagementObjectSearcher("SELECT * FROM Win32_WMISetting") ;
ManagementObjectCollection items = query.Get();
foreach (ManagementObject mo in items)
{
    System.Console.WriteLine(mo["BuildVersion"]);
}

There should only be one thing in the items collection since that setting is a singleton. "BuildVersion" is the WMI version that is installed.

EDIT:

Helen's comment below gives an even more succinct solution:

System.Console.WriteLine(
       (new ManagementObject("Win32_WMISetting=@"))["BuildVersion"]);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜