View Single Post
  #1 (permalink)  
Old 10-20-2008, 01:32 AM
N1c0_ds N1c0_ds is offline
Senior Member
 
Join Date: Sep 2008
Posts: 161
Default Checking if registry key exists?

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:
Code:
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?
Reply With Quote