Hi there
I use the following function to retrieve a string value from the registry:
but after Ive called this a couple of thousand times, I get this error Object reference not set to an instance of an object on the indicated line. What am I doing wrong? Are there better ways to read from the registry?
Thanx
I use the following function to retrieve a string value from the registry:
Code:
Public Function GetRegValue(ByVal psPath As String, ByVal psKey As String) As String
Dim lsValue As String
Dim loRegKey As RegistryKey
Try
loRegKey = Registry.LocalMachine.OpenSubKey(psPath)
[COLOR=red]lsValue = loRegKey.GetValue(psKey).ToString[/COLOR]
Catch
lsValue = ""
Finally
Registry.LocalMachine.Close()
loRegKey = Nothing
GetRegValue = lsValue
End Try
End Function
but after Ive called this a couple of thousand times, I get this error Object reference not set to an instance of an object on the indicated line. What am I doing wrong? Are there better ways to read from the registry?
Thanx
Last edited by a moderator: