Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2805
  • Last Modified:

Get string value from registry key

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
beef137
Asked:
beef137
1 Solution
 
Shahid ThaikaCommented:
0
 
jpaulinoCommented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
agriesserCommented:
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
 
DxpertCommented:
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
 
beef137Author Commented:
Thank you guys for all the help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now