Solved

Get string value from registry key

Posted on 2008-06-23
6
2,781 Views
Last Modified: 2008-06-23
I am using Visual Studio 2008, language Visual Basic. How can I get the string value from registry key "HKEY_CURRENT_USER\Software\Test\LastUser" and plug its value into a textbox? Thanks in advanced.
0
Comment
Question by:beef137
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Expert Comment

by:Shahid Thaika
ID: 21846654
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 21846677
Try this way:

Dim strKey As String = "HKEY_CURRENT_USER\Software\Test\"
Dim strValue As String = "LastUser"
Me.TextBox1.Text = My.Computer.Registry.GetValue(strKey, strValue, String.Empty)

Open in new window

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 21846682
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 14

Expert Comment

by:agriesser
ID: 21846683
Can't test at the moment, but out of mind it could look like this:
string = Registry.GetSettingString(HKEY_CURRENT_USER, "SOFTWARE\Test", "LastUser", "")
MsgBox string

Open in new window

0
 
LVL 10

Expert Comment

by:Dxpert
ID: 21846713
I guess (I didn't test it) it would be something like this:



Dim NewKey As RegistryKey = _
   Registry.CurrentUser.OpenSubKey("Software\Test\\LastUser", _
                                    True)
'Get value stored, and use a Type Conversion function to convert
'the Value from the Registry to a String

Dim GetVal As String = CType(NewKey.GetValue("LastUser"), _
                             String)
'Display the value on the Titlebar of the Form

Me.Text = GetVal



http://www.codeguru.com/vb/gen/vb_system/directoriesandfiles/article.php/c12067__2/
0
 

Author Comment

by:beef137
ID: 21846750
Thank you guys for all the help!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question