reading registry value

ninjaimp

Well-known member
Joined
Jun 13, 2007
Messages
80
Programming Experience
1-3
hi

I thought this was simple so i guess i am doing something wrong.
I want to read the value of an item in the registry.

the value im after is the centralprofile key which im trying to get by passing the SID and looking up the subkey but it never returns anything.

my code

VB.NET:
Function getprofilepath(ByVal SID As String) As String
        Try
            regKey = Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & SID, False)
            If Not regKey Is Nothing Then
                Return CType(regKey.GetValue("CentralProfile"), String)
            End If
        Catch ex As Exception

        End Try


        Return ""
    End Function

I know that the SID being passed is correct so any thoughts are appreciated.
 
solved it.

used this instead

Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & SID, "CentralProfile", "")
 
problem with first:
.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE
LocalMachine key doesn't have a subkey named 'HKEY_LOCAL_MACHINE'... :)
 

Latest posts

Back
Top