如何修改注册表的键值
若如下创建了子键“A001”及其键值“value1”,如何更改该键值(value1)的值。
Dim subKey As RegistryKey = Registry.CurrentUser.CreateSubKey("A001")
subKey.SetValue("value1", "000001")
[解决办法]
http://xly3000.blog.163.com/blog/static/132424720107119268104/
[解决办法]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If MessageBox.Show("修改注册表后,WINDOWS启动直接进入应用系统,而不显示桌面,是否确认修改?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question).ToString = "OK" Then
Dim myStr, myStr1, mystr2 As String
myStr1 = AppDomain.CurrentDomain.BaseDirectory.ToString
mystr2 = AppDomain.CurrentDomain.FriendlyName
mystr2 = Mid(mystr2, 1, InStr(mystr2, ".") - 1)
myStr = myStr1 + mystr2 + ".exe"
Dim hkLM As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine
Dim key As Microsoft.Win32.RegistryKey = hkLM.OpenSubKey("SOFTWARE\Microsoft\windows NT\CurrentVersion\Winlogon", True)
key.SetValue("Shell", myStr)
MsgBox("注册表已修改,电脑重启进入系统!")
'重启()
System.Diagnostics.Process.Start("shutdown.exe", " -r -t 00")
End If
[解决办法]
#Region "创建注册表中的键"
''' <summary>
''' 创建注册表中的键
''' </summary>
''' <remarks></remarks>
Private Sub CreatKey()
Dim Key1 As Microsoft.Win32.RegistryKey
Key1 = My.Computer.Registry.CurrentUser
Dim Key2 As Microsoft.Win32.RegistryKey
Key2 = Key1.OpenSubKey("RegTest", True) '返回当前用户键下的northsnow键,
If Key2 Is Nothing Then
Key2 = Key1.CreateSubKey("RegTest") '如果键不存在就创建它
End If
End Sub
#End Region
Call CreatKey()
Dim Key1 As Microsoft.Win32.RegistryKey
Key1 = My.Computer.Registry.CurrentUser
Dim Key2 As Microsoft.Win32.RegistryKey
Key2 = Key1.OpenSubKey("RegTest", True) '返回当前用户键下的northsnow键,
Try
'创建项,如果不存在就创建,如果存在则覆盖
Key2.SetValue("DBServer", "sa")
Key2.SetValue("password", "123")
Catch ex As Exception
End Try