A
Aussie Rules
Hi,
I want to store some data in the registry, however I have not been able to
do this, and think my logic maybe flawed.
Firstly I try to open the registry and read in any existing values.
Dim aKey As RegistryKey
aKey = Registry.CurrentUser.OpenSubKey("software\myApplication")
I then attempt to read in any existing values
strServerName = aKey.GetValue("ServerName")
strLoginName = aKey.GetValue("LoginName")
When the first getValue is executed, i get an error 'object reference not
set to an instance of an object', which I guess is fine as this registry
entry doesn't exist yet.
If the registry entry doesn't exist (say first time the application is run),
then I capture the error on the above code and create the registry subkey=
Registry.CurrentConfig.CreateSubKey("software\myApplication") ' No error on
this line
After the user has logged in, i want to save the user id and server name to
the registry, so that next time they use the program, step 1 will populate
the login form with the last login details used.
aKey.SetValue("ServerName", frmSPlash.txtServer.Text)
aKey.SetValue("LoginName", frmSPlash.txtUserID.Text)
When the first setvalue is execute i get an error 'object reference not set
to an instance of an object'. which i would not expect as it should be just
creating the entry.
What have I done wrong here......
THanks
I want to store some data in the registry, however I have not been able to
do this, and think my logic maybe flawed.
Firstly I try to open the registry and read in any existing values.
Dim aKey As RegistryKey
aKey = Registry.CurrentUser.OpenSubKey("software\myApplication")
I then attempt to read in any existing values
strServerName = aKey.GetValue("ServerName")
strLoginName = aKey.GetValue("LoginName")
When the first getValue is executed, i get an error 'object reference not
set to an instance of an object', which I guess is fine as this registry
entry doesn't exist yet.
If the registry entry doesn't exist (say first time the application is run),
then I capture the error on the above code and create the registry subkey=
Registry.CurrentConfig.CreateSubKey("software\myApplication") ' No error on
this line
After the user has logged in, i want to save the user id and server name to
the registry, so that next time they use the program, step 1 will populate
the login form with the last login details used.
aKey.SetValue("ServerName", frmSPlash.txtServer.Text)
aKey.SetValue("LoginName", frmSPlash.txtUserID.Text)
When the first setvalue is execute i get an error 'object reference not set
to an instance of an object'. which i would not expect as it should be just
creating the entry.
What have I done wrong here......
THanks