Checking for a registry value...

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?
 
S

sloan

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
 
G

Guest

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?
 
Joined
Oct 9, 2006
Messages
1
Reaction score
0
This is nice... but can you expland on this and tell how I would be able to check the value of a key? Say the Key was HKLM\software\......\ibm\effected and I wanted to see if the value was "YES" I then want to be able to create a text file. Is this possible? Well i know it is but can someone shed some light?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top