Checking for a registry value...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I lookup registry values?

I'd like to check for the existence of this folder in the registry:
HKLM\Software\AcmeCompany\MWIApplications\AutoLogonForSharedWorkstations

so that I can use a login prompt for only these machines.

Has anyone ever done this?
 
Here is some old old vb.net code I dug up.
Notice the imports and the bad hungarian notation.




Imports Microsoft.Win32

Public Class RegReader


Public Shared Function ReadRegValue(ByVal strKeyName As String) As
String

Dim regVersion As RegistryKey
Dim keyValue As String

keyValue = "SOFTWARE\\MySubThingLikeMicrosoft"
regVersion = Registry.LocalMachine.OpenSubKey(keyValue, False)
Dim strRegistryValue As String
strRegistryValue = string.Empty
If (Not regVersion Is Nothing) Then
strRegistryValue = regVersion.GetValue(strKeyName, "")
regVersion.Close()
End If

return strRegistryValue

End Function



End Class
 
This is very helpful - will this bring up any 'Security' errors if the
machine that my application runs this code on doesn't have admin rights?
 
Back
Top