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

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", "")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.