In my service, I have the following function 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 Try RegKey = Registry.CurrentUser.OpenSubKey(sPath) kValue = CStr(RegKey.GetValue(nKey)) Catch ex As Exception StartLogFile(" GetKeyValue " & vbNewLine & "Stack Trace= " & ex.StackTrace, EventLogEntryType.Warning) End Try End If Return kValue End Function
the same function works fine in Windows form, but if I call from a service, it cannot read the value. Does anyone know what is going on?
source share