My applications typically run in a Citrix/Terminal Services environment.
I have installed applications in the past and have run into problems with
regular users not being able to retrieve my application's settings because
they did not have adequate permissions to the registry key.
I have never created the keys during installation. Perhaps the permissions
are different when creating the keys during installation using the Registry
Editor in Visual Studio?
I have always created and manipulated keys using the following code:
Sub ReadRegistry(ByVal ParentKey As RegistryKey, ByVal SubKey As String, _
ByVal ValueName As String, ByRef Value As Object)
Dim Key As RegistryKey
Try
'Open the registry key.
Key = ParentKey.OpenSubKey(SubKey, True)
If Key Is Nothing Then 'if the key doesn't exist
'Throw New Exception("The registry key doesn't exist")
End If
'Get the value.
Value = Key.GetValue(ValueName)
Console.WriteLine("Value:{0} for {1} is successfully retrieved.", Value,
ValueName)
Catch e As Exception
Console.WriteLine("Error occurs in ReadRegistry" & e.Message)
End Try
End Sub
Sub WriteRegistry(ByVal ParentKey As RegistryKey, ByVal SubKey As String, _
ByVal ValueName As String, ByVal Value As Object)
Dim Key As RegistryKey
Try
'Open the registry key.
Key = ParentKey.OpenSubKey(SubKey, True)
If Key Is Nothing Then 'if the key doesn't exist.
Key = ParentKey.CreateSubKey(SubKey)
End If
'Set the value.
Key.SetValue(ValueName, Value)
Console.WriteLine("Value:{0} for {1} is successfully written.", Value,
ValueName)
Catch e As Exception
Console.WriteLine("Error occurs in WriteRegistry" & e.Message)
End Try
End Sub