Search all possible registry locations for the Heatmaster serial port.

This commit is contained in:
Michael Möller
2010-08-24 22:11:10 +00:00
parent 8112bfd205
commit 0d091fe5f2
2 changed files with 15 additions and 15 deletions

View File

@@ -69,23 +69,23 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
private static string[] GetRegistryPortNames() { private static string[] GetRegistryPortNames() {
List<string> result = new List<string>(); List<string> result = new List<string>();
string[] paths = { "", "&MI_00" };
try { try {
foreach (string path in paths) {
RegistryKey key = Registry.LocalMachine.OpenSubKey( RegistryKey key = Registry.LocalMachine.OpenSubKey(
@"SYSTEM\CurrentControlSet\Enum\USB\VID_10C4&PID_EA60"); @"SYSTEM\CurrentControlSet\Enum\USB\VID_10C4&PID_EA60" + path);
if (key == null)
key = Registry.LocalMachine.OpenSubKey(
@"SYSTEM\CurrentControlSet\Enum\USB\VID_10C4&PID_EA60&MI_00");
if (key != null) { if (key != null) {
foreach (string subKeyName in key.GetSubKeyNames()) { foreach (string subKeyName in key.GetSubKeyNames()) {
RegistryKey subKey = RegistryKey subKey =
key.OpenSubKey(subKeyName + "\\" + "Device Parameters"); key.OpenSubKey(subKeyName + "\\" + "Device Parameters");
if (subKey != null) { if (subKey != null) {
string name = subKey.GetValue("PortName") as string; string name = subKey.GetValue("PortName") as string;
if (name != null) if (name != null && !result.Contains(name))
result.Add((string)name); result.Add((string)name);
} }
} }
} }
}
} catch (SecurityException) { } } catch (SecurityException) { }
return result.ToArray(); return result.ToArray();
} }

View File

@@ -38,5 +38,5 @@
using System; using System;
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("0.1.37.8")] [assembly: AssemblyVersion("0.1.37.9")]
[assembly: AssemblyFileVersion("0.1.37.8")] [assembly: AssemblyFileVersion("0.1.37.9")]