//写注册表 Dim loca As RegistryKey = Registry.LocalMachine Dim run As RegistryKey = loca.CreateSubKey("SOFTWARE\NetLogin") run.SetValue("UserName", txtUsername.Text.Trim) run.SetValue("password", txtPwd.Text.Trim)//读注册表 Dim name As String = "" Dim password As String = "" Dim loca As RegistryKey = Registry.LocalMachine Dim run As RegistryKey = loca.CreateSubKey("SOFTWARE\NetLogin") name = run.GetValue("UserName") password = run.GetValue("password")
如果选中,在登陆后就把用户名和密码写到文件或注册表中
下次登陆自动读取出来。读的时候判断下是否设置自动登陆,没设置就不读如果取消自动登陆,可以清除对应的记录。不清楚当然也可以,因为前面判断了,就不会去读了
//写注册表
Dim loca As RegistryKey = Registry.LocalMachine
Dim run As RegistryKey = loca.CreateSubKey("SOFTWARE\NetLogin")
run.SetValue("UserName", txtUsername.Text.Trim)
run.SetValue("password", txtPwd.Text.Trim)//读注册表
Dim name As String = ""
Dim password As String = ""
Dim loca As RegistryKey = Registry.LocalMachine
Dim run As RegistryKey = loca.CreateSubKey("SOFTWARE\NetLogin")
name = run.GetValue("UserName")
password = run.GetValue("password")
在.NET下可以使用 独立存储
http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.aspx