public static string [] GetCommKeys() ... { string[] values = null; try ...{ RegistryKey hklm = Registry.LocalMachine; RegistryKey hs = hklm.OpenSubKey("HARDWARE/DEVICEMAP/SERIALCOMM"); //Console.WriteLine(hs.ValueCount.ToString()); values = new string[hs.ValueCount]; for (int i = 0; i < hs.ValueCount; i++) ...{ values[i] = hs.GetValue(hs.GetValueNames()[i]).ToString(); } } catch (Exception ee) ...{ MessageBox.Show(ee.Message); } return values; }