Registry Pada Visual Basic .NET

Posted On // Leave a Comment
Module

Public Sub ___RegistrySet(ByVal _strRegSubKey As String, _
                               ByVal _strRegValue As String)

        Dim _RegistryKey As RegistryKey
        _RegistryKey = Registry.LocalMachine

        Dim _RegistrySubKey As RegistryKey
        _RegistrySubKey = _RegistryKey.OpenSubKey("SOFTWARE\SMSAdv\Setting", True)
        If _RegistrySubKey Is Nothing Then
            _RegistrySubKey.CreateSubKey("SOFTWARE\SMSAdv\Setting")
        Else
            _RegistrySubKey.SetValue(_strRegSubKey, _strRegValue)
        End If

        _RegistryKey.Close()

    End Sub

    Public Function ___RegistryGet(ByVal _strRegValue As String) As String

        Dim _RegistryKey As RegistryKey
        _RegistryKey = Registry.LocalMachine

        Dim _RegistrySubKey As RegistryKey
        _RegistrySubKey = _RegistryKey.OpenSubKey("SOFTWARE\SMSAdv\Setting", True)
        Return _RegistrySubKey.GetValue(_strRegValue)

    End Function

'GET REGISTRY VALUE
CBEModem.EditValue = ___RegistryGet("Modem")

'SET REGISTRY
___RegistrySet("Database", TEDatabase.EditValue.ToString.Trim)

0 komentar: