21 | 08 | 2017

Write/Read registry value .NET

 Code below shows how to write and read values to and from  the registry.

    Public Sub Writevalue()
 
        '*************************************
        '**** Code from VisibleVisual.com ****
        '*************************************
        Dim regKey As RegistryKey
        Dim keyTop As RegistryKey = Registry.CurrentUser
 
        regKey = keyTop.OpenSubKey("Software\MyCompany\MyApp", True)
        If regKey Is Nothing Then
            regKey = keyTop.CreateSubKey("Software\MyCompany\MyApp")
        End If
 
        Dim binValue As Byte() = {&HF0, &HFF, &H12, &HE0, &H43, &HAC}
        Dim strngValue As String() = {"A", "B", "C", "D"}
 
        regKey.SetValue("WindowState", 0, RegistryValueKind.DWord)
        regKey.SetValue("CustomWindowCaption", "Client Contact Management", RegistryValueKind.String)
 
        'regKey.SetValue("CustomPosition", binValue, RegistryValueKind.Binary)
        'regKey.SetValue("CustomLabels", strngValue, RegistryValueKind.MultiString)
 
 
    End Sub
 
 
    Public Sub ReadValue()
 
        MsgBox (My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\MyCompany\MyApp\", "CustomWindowCaption", "0"))
 
    End Sub
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2330668
Latest Articles