日期:2014-05-18 浏览次数:21067 次
try { var searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData"); foreach (ManagementObject queryObj in searcher.Get())//执行到in时出错,消息:“不受支持” { Console.WriteLine("-----------------------------------"); Console.WriteLine("MSStorageDriver_ATAPISmartData instance"); Console.WriteLine("-----------------------------------"); var arrVendorSpecific = (byte[])queryObj.GetPropertyValue("VendorSpecific"); // Create SMART data from 'vendor specific' array var d = new SmartData(arrVendorSpecific); foreach (var b in d.Attributes) { Console.Write("{0} :{1} : ", b.AttributeType, b.Value); foreach (byte vendorByte in b.VendorData) { Console.Write("{0:x} ", vendorByte); } Console.WriteLine(); Console.ReadLine(); } } } catch (ManagementException e) { Console.WriteLine("An error occurred while querying for WMI data: " + e.Message); }