Within my service i have the following function in order to take some values from my registry:
Public Function GetKeyValue(ByVal nKey As String, ByVal sPath As String) As String
Dim RegKey As RegistryKey
Dim kValue As String = Nothing
Dim Pos As String
If CheckRegistry(sPath) Then
RegKey = Registry.CurrentUser.OpenSubKey(sPath)
kValue = CStr(RegKey.GetValue(nKey))
Catch ex As Exception
StartLogFile(" GetKeyValue " & vbNewLine & "Stack Trace= " & ex.StackTrace, EventLogEntryType.Warning)
You should not store your data in
HKEY_CURRENT_USER but under
HKEY_LOCAL_MACHINE that makes more sense for a Windows-Service.
Be also aware that you can also set Permissions on Registry Keys. Check also that when try reading.