Get Value from Registry using VB.NET

  • Thread starter Thread starter A_PK
  • Start date Start date
Here's a very simple example:

Imports Microsoft.Win32

Private Function GetRegistryValue(ByVal sKey As String, ByVal sKeyName
As String) As String
Dim reg As RegistryKey
Dim strTemp As String
reg = Registry.CurrentUser.OpenSubKey(sKey)
reg.OpenSubKey(strKey)
If Not (reg Is Nothing) Then
strTemp = reg.GetValue(sKeyName)
reg.Close()
End If
Return strTemp
End Function

I have just coded it for HKEY_CURRENT_USER & it doesn't include any error
trapping, but you get the idea

Crouchie1998
BA (HONS) MCP MCSE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top