Retrieve String Name & Data Value From Within Registry Key

  • I know that the following will load all of the String Names (i.e. all instances of SQL Server) into my ComboBox ...

    RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");

    foreach (var v in key.GetValueNames())

    {

    KAELCcomboBox1.Items.Add(v);

    }

    When I select an option from the dropdown box I can then assign that to a string variable named mySQL.

    However, if there is only one instance of SQL Server on the PC and I know that, how do I select that single String Name and save that to mySQL ?

  • Sorted ... mySQL = key.GetValueNames().First();

    gary.p.heath (3/22/2012)


    I know that the following will load all of the String Names (i.e. all instances of SQL Server) into my ComboBox ...

    RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");

    foreach (var v in key.GetValueNames())

    {

    KAELCcomboBox1.Items.Add(v);

    }

    When I select an option from the dropdown box I can then assign that to a string variable named mySQL.

    However, if there is only one instance of SQL Server on the PC and I know that, how do I select that single String Name and save that to mySQL ?

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply