G
Guest
I've written a service program in VB.NET and I can't seem to get it to be able to read entries in the registry. Is there some trick to this? I have a windows program that reads and writes the same registry entries and it works fine. I'm using the exact same code in the service program to read the registry entries but it always returns nothing, so my program won't start because I'm trying to assign a null value to a variable. Any assistance would be greatly appreciated
Here's some of my code...
Dim Value As Objec
ReadRegistry(Registry.LocalMachine, "Software\DotBoard", "Database Location", Value
DataBasePath = Value.ToStrin
Function ReadRegistry(ByVal ParentKey As RegistryKey, ByVal SubKey As String,
ByVal ValueName As String, ByRef Value As Object
Dim Key As RegistryKe
Tr
'Open the registry key
Key = ParentKey.OpenSubKey(SubKey, True
If Key Is Nothing Then 'if the key doesn't exis
Throw New Exception("The registry key doesn't exist"
End I
'Get the value
ReadRegistry = Key.GetValue(ValueName
Catch e As Exceptio
End Tr
End Function
Here's some of my code...
Dim Value As Objec
ReadRegistry(Registry.LocalMachine, "Software\DotBoard", "Database Location", Value
DataBasePath = Value.ToStrin
Function ReadRegistry(ByVal ParentKey As RegistryKey, ByVal SubKey As String,
ByVal ValueName As String, ByRef Value As Object
Dim Key As RegistryKe
Tr
'Open the registry key
Key = ParentKey.OpenSubKey(SubKey, True
If Key Is Nothing Then 'if the key doesn't exis
Throw New Exception("The registry key doesn't exist"
End I
'Get the value
ReadRegistry = Key.GetValue(ValueName
Catch e As Exceptio
End Tr
End Function