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"]);
精彩评论