I'm trying to get the value of a registry sub-key that I know exists. The code I'm using is:
private void button11_Click(object sender, EventArgs e)
{
try
{
RegistryKey newKey = Registry.LocalMachine;
newKey = newKey.OpenSubKey(@"\SOFTWARE\CyberLink\PowerDVD21");
string loc = newKey.GetValue("OpenWithMUI").ToString();
newKey.Close();
MessageBox.Show("Main Dir: " + loc);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(),"ERROR",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
When I click on the button that the code is attached to, I get this:

When I did research, it looked like what I was doing was correct. So what am I doing wrong?
Thanks for the help.


antony parackaRank #5,346 · 302 reputationPosted Sep 5, 2022, 8:32 AM EDT
use
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\OurSettings");
Then
key.GetValue("Value");
Vishal YelveRank #178 · 13.6K reputationPosted Sep 6, 2022, 5:12 AM EDT