Add a Registry Key


Public Function AddKeyValue(ByVal Reg_Key_Path As String, ByVal Key_Value As String, _ 
                                    ByVal strValueToAdd As String) 
        '**************************************************************************************************** 
        'FUNCTION: creates a value for a specific registry key 
        '**************************************************************************************************** 
        Dim reg_key As RegistryKey 

        Try 
            'ensure that the key has WRITABLE = TRUE!! 
            reg_key = Registry.LocalMachine.OpenSubKey(Reg_Key_Path, True) 
            reg_key.SetValue(Key_Value, strValueToAdd) 
            reg_key.Close() 
        Catch uae As UnauthorizedAccessException 
            Throw New UnauthorizedAccessException("You don't have the necessary " & _ 
                                "permissions to do this." & vbNewLine & uae.Message, uae) 
        End Try 
    End Function