Solved

Get string value from registry key

Posted on 2008-06-23
6
2,789 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month3 days, 11 hours left to enroll

630 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