I have the following code which should read/write from the registry but it seems it doesn't do anything and C# 2008 doesn't report any errors.
Here is the write sequence:
pb8.Value = (pb8.Value + 1);
RegistryKey registry = Registry.LocalMachine.CreateSubKey(@"SOF...
if (registry != null)
{
registry.SetValue("TheValue", pb8.Value);
registry.Close();
}
And here is the read sequence:
RegistryKey registry = Registry.LocalMachine.CreateSubKey(@"SOF...
if (registry != null)
{
pb8.Value = Convert.ToInt32(registry.GetValue("TheVa...
registry.Close();
}
tmrBegin.Enabled = false;
Note: pb8 is a progress bar, which I'm using to read/write the registry value into. Also, this
code is placed into two timers, so the value of pb8 is increased by 1 every second.
|
Newbie Member
|
|
| 4Jun2009,05:21 | #2 |
|
Sorry, the text in the post above didn't paste as it should.
Here is the correct (full one): Hi, I have the following code which should read/write from the registry but it seems it doesn't do anything and C# 2008 doesn't report any errors. Here is the write sequence: Code:
pb8.Value = (pb8.Value + 1);
RegistryKey registry = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\\Test");
if (registry != null)
{
registry.SetValue("RegisteredOwner", pb8.Value);
registry.Close();
}
Code:
RegistryKey registry = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\\Test");
if (registry != null)
{
pb8.Value = Convert.ToInt32(registry.GetValue("RegisteredOwner"));
registry.Close();
}
tmrBegin.Enabled = false;
code is placed into two timers, so the value of pb8 is increased by 1 every second. |
