vb.net操作注册表

Imports Microsoft.Win32

Module Module1

    Sub Main()


        Dim regPath As String = "某某系统\Seting"


        Dim Key1 As Microsoft.Win32.RegistryKey = Registry.CurrentUser


        Dim Key2 = Key1.OpenSubKey("某某系统")

        Dim regkey1 As RegistryKey = Registry.CurrentUser.OpenSubKey(regPath, True)

        regkey1.SetValue("OperatorPsw", "OperatorPsw")
        regkey1.SetValue("EngineerPsw", "EngineerPsw")

        regkey1.Close()

        Dim regKey2 As RegistryKey = Registry.CurrentUser.OpenSubKey(regPath, RegistryKeyPermissionCheck.Default, System.Security.AccessControl.RegistryRights.ReadKey)
        If Not regKey2 Is Nothing Then
            Dim OperatorPsw = regKey2.GetValue("OperatorPsw")
            Dim EngineerPsw = regKey2.GetValue("EngineerPsw")

            regKey2.Close()
            Console.WriteLine(OperatorPsw)
            Console.WriteLine(EngineerPsw)
        Else
            Console.WriteLine("未获取数据")
        End If
    End Sub

End Module

  

posted on 2017-07-21 16:58  小白兔与小灰兔  阅读(188)  评论(0编辑  收藏  举报