I want to save my application settings to the registry. I want to check if keys exist and create a key if they don't.
It's easy to do it for one key only with errorlabel:
But if there is more than one entry (it's for the whole skin + all the settings), it makes much less safe. Let's say only 1 of the entries is missing. Using this method, we would have to rewrite every registry entry to the default value, thus erasing the user's settings.
Is there a "FileExist" for the registry keys?
It's easy to do it for one key only with errorlabel:
B4X:
Sub Loadsettings
ErrorLabel(KeyNotFound)
TxtServerPath.Text=Registry.GetValue(Regpath,"ServerURL")
Return
KeyNotFound:
Registry.CreateSubKey("",Regpath)
Registry.SetStringValue(Regpath,"ServerURL","http://ayvegh.com/~nico/")
End Sub
But if there is more than one entry (it's for the whole skin + all the settings), it makes much less safe. Let's say only 1 of the entries is missing. Using this method, we would have to rewrite every registry entry to the default value, thus erasing the user's settings.
Is there a "FileExist" for the registry keys?