Solved

Get string value from registry key

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

Expert Comment

by:Éric Moreau
ID: 21846682
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a Condition in ASP Repeater 6 44
VS 2017 18 101
Selenium: Transitioning from unit testing to automated testing 4 55
Macro problems with Excel file 6 22
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

685 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