REM 设置根节点
Private key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser
Function readKey(path, Optional ByVal value = "")
Dim subkey As Microsoft.Win32.RegistryKey
subkey = key.OpenSubKey(path, False)
If subkey Is Nothing Then
addKey(path, value) '不存在就把创建一个并把value写进去
subkey = key.OpenSubKey(path, False)
End If
Return subkey.GetValue("") '注册表子结点
End Function
Sub modifyKey(path, value)
Dim subkey As Microsoft.Win32.RegistryKey
subkey = key.OpenSubKey(path, True)
subkey.SetValue("", value, Microsoft.Win32.RegistryValueKind.String)
End Sub
Sub addKey(path, value)
Dim subkey As Microsoft.Win32.RegistryKey
subkey = key.CreateSubKey(path)
subkey.SetValue("", value, Microsoft.Win32.RegistryValueKind.String)
End Sub
Sub addKey(path, value)
Dim key As Microsoft.Win32.RegistryKey
Dim subkey As Microsoft.Win32.RegistryKey
key = Microsoft.Win32.Registry.CurrentUser
subkey = key.CreateSubKey(path)
subkey.SetValue("", value, Microsoft.Win32.RegistryValueKind.String)
End Sub
Sub safeOpeningForm()
Dim passPath = "Software\a\x"
Dim endDatePath = "Software\a\y"
Dim startDatePath = "Software\a\z"
Dim r1 = readKey(passPath)
Dim r2 = readKey(endDatePath)
Dim r3 = readKey(startDatePath)
End Sub
流泪的小狼 发布了25 篇原创文章 · 获赞 14 · 访问量 3万+ 私信 关注