I tired the code example that you provided and things seem to work but? I'm
not sure why I needed to use an "CreateSubKey" vs a OpenSubkey since all I
want to do is read from the registry the specified key
However, a bigger issue has to do with the use of "GetValue" it doesn't
work. The only thing that it returns is the defaul value. I've checked to
make sure that the sub exist and results are the same. According to the
documentation the default value is not required but that is all that is
returned. In my case it also appears that ODBC connections do not work in
the .net world. I'm still investigating that.
Have you experience this type of behavior also?
Thanks
"Ken Tucker [MVP]" wrote:
Hi,
Dim myReg As RegistryKey = Registry.LocalMachine
Dim MyRegKey As RegistryKey
Dim MyVal As String
MyRegKey = myReg.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion")
MyVal = MyRegKey.GetValue("ProductID")
Trace.WriteLine(MyRegKey.GetValue("ProductID"))
Trace.WriteLine(MyRegKey.GetValue("RegisteredOwner "))
MyRegKey.Close()
Ken
----------------------------------
"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
I'm trying to read a registry key using VB.Net. I have posted the code below
that I'm using:
Dim DBConnect As RegistryKey = Registry.CurrentUser.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile Control\SageQuestSetup")
Dim AlertDB As String = CType(DBConnect.GetValue("ConnectionString"),
String)
Public AlertConnectionString As String = AlertDB
I've vaildated the key path and I continue to get nothing assigned to
DBConnect.
What am I doing wrong here?
Thanks
Are there more variables to set?