public static IList<SlxConnectionInfo> ListAllConnections()
{
List<SlxConnectionInfo> list = new List<SlxConnectionInfo>();
RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\SalesLogix\ADOLogin");
if (rk != null)
{
try
{
String[] connectionKeyNames = rk.GetSubKeyNames();
foreach (String keyName in connectionKeyNames)
{
RegistryKey conKey = rk.OpenSubKey(keyName);
try
{
if (conKey != null && !String.IsNullOrEmpty((String)conKey.GetValue("Data Source")))
{
list.Add(new SlxConnectionInfo()
{
Server = (String)conKey.GetValue("Data Source"),
Database = (String)conKey.GetValue("Initial Catalog"),
Alias = (String)conKey.GetValue("Alias")
});
}
}
finally
{
conKey.Close();
}
}
}
finally
{
rk.Close();
}
}
return list;
}