Hardware/SMBIOS/SMBIOSGroup.cs
changeset 39 654696eeebe8
parent 9 e5adb0fd4917
     1.1 --- a/Hardware/SMBIOS/SMBIOSGroup.cs	Tue Feb 09 19:42:33 2010 +0000
     1.2 +++ b/Hardware/SMBIOS/SMBIOSGroup.cs	Thu Feb 11 13:22:17 2010 +0000
     1.3 @@ -56,34 +56,34 @@
     1.4          return;
     1.5        
     1.6        List<Structure> structureList = new List<Structure>();
     1.7 -      
     1.8 +
     1.9        try {
    1.10          ManagementObjectCollection collection = new ManagementObjectSearcher(
    1.11            "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
    1.12 -  
    1.13 +
    1.14          byte[] raw = null;
    1.15          foreach (ManagementObject mo in collection) {
    1.16            raw = (byte[])mo["SMBiosData"];
    1.17            break;
    1.18 -        }      
    1.19 -      
    1.20 +        }
    1.21 +
    1.22          if (raw != null && raw.Length > 0) {
    1.23            int offset = 0;
    1.24            byte type = raw[offset];
    1.25            while (offset < raw.Length && type != 127) {
    1.26 -            
    1.27 +
    1.28              type = raw[offset]; offset++;
    1.29              int length = raw[offset]; offset++;
    1.30 -            ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]); 
    1.31 +            ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
    1.32              offset += 2;
    1.33 -            
    1.34 +
    1.35              byte[] data = new byte[length];
    1.36              Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
    1.37 -  
    1.38 +
    1.39              List<string> stringsList = new List<string>();
    1.40              if (raw[offset] == 0)
    1.41                offset++;
    1.42 -            while (raw[offset] != 0) {   
    1.43 +            while (raw[offset] != 0) {
    1.44                StringBuilder sb = new StringBuilder();
    1.45                while (raw[offset] != 0) {
    1.46                  sb.Append((char)raw[offset]); offset++;
    1.47 @@ -105,7 +105,7 @@
    1.48              }
    1.49            }
    1.50          }
    1.51 -      } catch (NotImplementedException) { }
    1.52 +      } catch (NotImplementedException) { } catch (ManagementException) { }
    1.53        
    1.54        table = structureList.ToArray();
    1.55      }