473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Reading a Registry Key

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?
Nov 21 '05 #1
11 2199
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?
Nov 21 '05 #2
I tried the code that you provided and I'm still getting the same results.
Could there something else I'm missing here?

I was reading further and ran across something about permissions. could
this be the problem?

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?

Nov 21 '05 #3
Larry,

Just from a program before my nose. (a very little bit changed)

Imports Microsoft.Win32

Dim Reg As RegistryKey = Registry.CurrentUser
Reg = Registry.CurrentUser.CreateSubKey("Software\FromMe \ThePart")
Me.ClientSize = New System.Drawing.Size(Reg.GetValue("Width",100),
Reg.GetValue("Height",100))

I hope this helps?

Cor
Nov 21 '05 #4
I have been really struggling with this since yesterday afternoon and no luck
yet. Here's a copy of my code. please tell me what I'm doing wrong.

Dim SageQuestRegistry As RegistryKey = Registry.CurrentUser

Dim SageQuestDB As RegistryKey

Dim AlertConnectionString As String

SageQuestDB = SageQuestRegistry.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile
Control\SageQuestSetup")

AlertConnectionString = SageQuestDB.GetValue("ConnectionString")

SageQuestDB.Close()

I've verifed that the key does exist.
thanks

"Cor Ligthert" wrote:
Larry,

Just from a program before my nose. (a very little bit changed)

Imports Microsoft.Win32

Dim Reg As RegistryKey = Registry.CurrentUser
Reg = Registry.CurrentUser.CreateSubKey("Software\FromMe \ThePart")
Me.ClientSize = New System.Drawing.Size(Reg.GetValue("Width",100),
Reg.GetValue("Height",100))

I hope this helps?

Cor

Nov 21 '05 #5
Larry,

Did you do it the way I do just creating that subkey before you read it?
As I remember me I did not get it to work as well not with your method.
(I am not sure anymore about this, however I thought as well that I saw
persons who did it like you and did not succeed).

The took the methode I take and they said than ........................

Cor

"Larry Bird" <La*******@discussions.microsoft.com>
I have been really struggling with this since yesterday afternoon and no
luck
yet. Here's a copy of my code. please tell me what I'm doing wrong.

Dim SageQuestRegistry As RegistryKey = Registry.CurrentUser

Dim SageQuestDB As RegistryKey

Dim AlertConnectionString As String

SageQuestDB = SageQuestRegistry.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile
Control\SageQuestSetup")

AlertConnectionString =
SageQuestDB.GetValue("ConnectionString")

SageQuestDB.Close()

I've verifed that the key does exist.
thanks

"Cor Ligthert" wrote:
Larry,

Just from a program before my nose. (a very little bit changed)

Imports Microsoft.Win32

Dim Reg As RegistryKey = Registry.CurrentUser
Reg = Registry.CurrentUser.CreateSubKey("Software\FromMe \ThePart")
Me.ClientSize = New System.Drawing.Size(Reg.GetValue("Width",100),
Reg.GetValue("Height",100))

I hope this helps?

Cor

Nov 21 '05 #6
Could this be a case that I don't have permission to read the registry
entiry? If so how do I set the permissions to read?

"Cor Ligthert" wrote:
Larry,

Just from a program before my nose. (a very little bit changed)

Imports Microsoft.Win32

Dim Reg As RegistryKey = Registry.CurrentUser
Reg = Registry.CurrentUser.CreateSubKey("Software\FromMe \ThePart")
Me.ClientSize = New System.Drawing.Size(Reg.GetValue("Width",100),
Reg.GetValue("Height",100))

I hope this helps?

Cor

Nov 21 '05 #7
For me the key already exist. So I'm trying to read a key created and is
being used in VB 6.

Thanks
"Cor Ligthert" wrote:
Larry,

Did you do it the way I do just creating that subkey before you read it?
As I remember me I did not get it to work as well not with your method.
(I am not sure anymore about this, however I thought as well that I saw
persons who did it like you and did not succeed).

The took the methode I take and they said than ........................

Cor

"Larry Bird" <La*******@discussions.microsoft.com>
I have been really struggling with this since yesterday afternoon and no
luck
yet. Here's a copy of my code. please tell me what I'm doing wrong.

Dim SageQuestRegistry As RegistryKey = Registry.CurrentUser

Dim SageQuestDB As RegistryKey

Dim AlertConnectionString As String

SageQuestDB = SageQuestRegistry.OpenSubKey _
("Software\VB and VBA Program Settings\Mobile
Control\SageQuestSetup")

AlertConnectionString =
SageQuestDB.GetValue("ConnectionString")

SageQuestDB.Close()

I've verifed that the key does exist.
thanks

"Cor Ligthert" wrote:
Larry,

Just from a program before my nose. (a very little bit changed)

Imports Microsoft.Win32

Dim Reg As RegistryKey = Registry.CurrentUser
Reg = Registry.CurrentUser.CreateSubKey("Software\FromMe \ThePart")
Me.ClientSize = New System.Drawing.Size(Reg.GetValue("Width",100),
Reg.GetValue("Height",100))

I hope this helps?

Cor


Nov 21 '05 #8
> For me the key already exist. So I'm trying to read a key created and is
being used in VB 6.


That does not matter

I use it forever in that way I showed you, did you try it already?

Cor
Nov 21 '05 #9
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?

Nov 21 '05 #10
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

"Cor Ligthert" wrote:
For me the key already exist. So I'm trying to read a key created and is
being used in VB 6.


That does not matter

I use it forever in that way I showed you, did you try it already?

Cor

Nov 21 '05 #11
All the code the we exchanged will work. The real problem was security. The
user ID that is signed must have the right permission to read or write to the
registry.

"Cor Ligthert" wrote:
For me the key already exist. So I'm trying to read a key created and is
being used in VB 6.


That does not matter

I use it forever in that way I showed you, did you try it already?

Cor

Nov 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Duncan Allen | last post by:
I'm trying to use aspnet_setreg to encrypt user names & password used in the web.config file for use in the indentity element. When the website runs I get the message 'Error reading the password...
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
6
by: Bry | last post by:
I'm having problems writing (and reading) boolean data to the registry. // Write a boolean value to the registry // I've not included the obvious bits of code in these samples bool myBool =...
1
by: Peter John | last post by:
I am using the following code to read from and write to the registry. The writing works fine but reading always fails. Can anyone suggest what is going wrong? Imports Microsoft.Win32 Public...
5
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
2
by: zoneal | last post by:
my program it's just tools for my little home network.. Only thing I have left to do is reading the registy key to check the path to the shared folder.. this path is always updated so I will...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
3
by: Aussie Rules | last post by:
Hi, I want to store some data in the registry, however I have not been able to do this, and think my logic maybe flawed. Firstly I try to open the registry and read in any existing values....
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.