Registry Values

M

MadCrazyNewbie

Hey Group,

Im trying to load up some registry Values and display them in Text Box's:

Here is my Code:

Dim RegKeyRead As RegistryKey
'reset the resulting textbox
txtNetworkDevelopmentPath.Text = ""
txtLiveLocalPath.Text = ""
txtLiveNetworkPath.Text = ""
'Try to open the given path
RegKeyRead = Registry.CurrentUser.OpenSubKey("Software\\Excellence",
True)
If RegKeyRead Is Nothing Then
'if the path doesn't exist, warn the user
MessageBox.Show("Error Found")
Exit Sub
End If
'retrieve the subkey and its value (alone with a default value if
the subkey is not found)
"Software\\Excellence" =
RegKeyRead.GetValue(txtNetworkDevelopmentPath.Text, "---Not
Found---").ToString
"Software\\Excellence" = RegKeyRead.GetValue(txtLiveLocalPath.Text,
"---Not Found---").ToString
"Software\\Excellence" =
RegKeyRead.GetValue(txtLiveNetworkPath.Text, "---Not Found---").ToString
'close the key
RegKeyRead.Close()

Only problem is I get a Sysntax Error on "Software\\Excellence".

Could anybody possibly point me in the right direction? also on my Line
"MessageBox.Show("Error Found") How could I get it to tell me which Reg Key
was not found?

Many Many Thanks
MCN
 
C

Cor Ligthert

Hi Mad,

I do it just like this
Dim RegKeyRead As RegistryKey
RegKeyRead = Registry.CurrentUser.CreateSubKey("Software\\Excellence")

I hope this helps?

Cor
 
M

MadCrazyNewbie

Sorry Cor,

Im confused? Would I do:

RegKeyRead = Registry.CurrentUser.GetValue("Software\\Excellence") =
(txtNetworkDevelopmentPath.Text, "---Not Found---").ToString

Many Thanks Again
MCN
 
C

Cor Ligthert

Hi Mad,

I thought it was the first Software\\Excellence that did give the errror,
however as thirth row I have than in a program

pConn = RegKeyRead.GetValue("ConnString", "").ToString

The second parameter is the default.

Do you understand it when you see this?

Cor
 
M

MadCrazyNewbie

Sorry Cor i think im confusing you:

I have in My Registry 3 Values under Software\\Excellence:

1. NetDevPath with Value of "J:\DevDB"
2. LiveLocalPath with a Value of "C:\LocalLiveDB"
3. LiveNetPath with a Value of "J:\LiveDB"

All the following lines give Syntax Errors on "Software\\Excellence"

"Software\\Excellence" = RegKeyRead.GetValue(txtNetworkDevelopmentPath.Text,
"---Not Found---").ToString
"Software\\Excellence" = RegKeyRead.GetValue(txtLiveLocalPath.Text, "---Not
Found---").ToString
"Software\\Excellence" = RegKeyRead.GetValue(txtLiveNetworkPath.Text,
"---Not Found---").ToString

So Am I correct in thinking?

Dim RegKeyRead As RegistryKey
RegKeyRead = Registry.CurrentUser.GetValue("Software\\Excellence") - Loads
up the Reg Area ("Software\\Excellence")

But how do I put the NetDevPath key Value into my txtNetworkDevelopmentPath
Text Box, and so on with LiveLocalPath and LiveNetPath?

Many Thanks
MCN
 
C

Cor Ligthert

Hi Mad,

Yes you confusing me, because I do not understand this code.
"Software\\Excellence" = RegKeyRead.GetValue(txtNetworkDevelopmentPath.Text,
"---Not Found---").ToString

That is something as
"MadCrazy" = "Doing Crazy"

Do you mean
txtNetworkDevelopmentPath.Text = RegKeyRead.GetValue(NetDevPath,"----Not
Found---").toString

I get the idea, that it is or very late at your place or that it maybe has
been very late.

Or maybe I see something not.

:))

Cor
 
M

MadCrazyNewbie

Hi Cor,

Yer sorry not late is about 12:00 dinner, just been an earlie morning:(

Now I have:

txtNetworkDevelopmentPath.Text = RegKeyRead.GetValue(NetDevPath, "----Not
Found---").toString
txtLiveLocalPath.Text = RegKeyRead.GetValue(LiveLocalPath, "----Not
Found---").toString
txtLiveNetworkPath.Text = RegKeyRead.GetValue(LiveNetworkPath, "----Not
Found---").toString

But in now Tells me that NetDevPath, LiveLocalPath, & LiveNetworkPath arn`t
Declared, how do I Declare them?

Is it just a Case of:

Dim NetDevPath As RegistaryKey?

Many Thanks
MCN
 
C

Cor Ligthert

Hi Mad,

I made them as a dataname, however I asume you want them between quotes,
just as a name.

Cor
 
H

Herfried K. Wagner [MVP]

* "MadCrazyNewbie said:
'Try to open the given path
RegKeyRead = Registry.CurrentUser.OpenSubKey("Software\\Excellence",

Replace the "\\" with "\" and try again.
 

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

Top