Solved

Get string value from registry key

Posted on 2008-06-23
6
2,733 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
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 69

Expert Comment

by:Éric Moreau
ID: 21846682
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now