A small bug fix for application crashes during the mainboard detection (System.Management.ManagementException: Not supported).

This commit is contained in:
Michael Möller
2010-02-11 13:22:17 +00:00
parent 0cc5a578c3
commit cd4360dbd3
2 changed files with 12 additions and 12 deletions
+10 -10
View File
@@ -56,34 +56,34 @@ namespace OpenHardwareMonitor.Hardware.SMBIOS {
return;
List<Structure> structureList = new List<Structure>();
try {
ManagementObjectCollection collection = new ManagementObjectSearcher(
"root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
byte[] raw = null;
foreach (ManagementObject mo in collection) {
raw = (byte[])mo["SMBiosData"];
break;
}
}
if (raw != null && raw.Length > 0) {
int offset = 0;
byte type = raw[offset];
while (offset < raw.Length && type != 127) {
type = raw[offset]; offset++;
int length = raw[offset]; offset++;
ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
offset += 2;
byte[] data = new byte[length];
Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
List<string> stringsList = new List<string>();
if (raw[offset] == 0)
offset++;
while (raw[offset] != 0) {
while (raw[offset] != 0) {
StringBuilder sb = new StringBuilder();
while (raw[offset] != 0) {
sb.Append((char)raw[offset]); offset++;
@@ -105,7 +105,7 @@ namespace OpenHardwareMonitor.Hardware.SMBIOS {
}
}
}
} catch (NotImplementedException) { }
} catch (NotImplementedException) { } catch (ManagementException) { }
table = structureList.ToArray();
}
+2 -2
View File
@@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.17.0")]
[assembly: AssemblyFileVersion("0.1.17.0")]
[assembly: AssemblyVersion("0.1.17.1")]
[assembly: AssemblyFileVersion("0.1.17.1")]