70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using Microsoft.Win32;
|
||
using System;
|
||
using System.Windows.Forms;
|
||
|
||
namespace C_Windows_1
|
||
{
|
||
public partial class LogOn : Form
|
||
{
|
||
private string user_pwd;
|
||
|
||
public LogOn()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void LogOn_Load(object sender, EventArgs e)
|
||
{
|
||
Password.Focus();
|
||
}
|
||
|
||
private void Log_Click(object sender, EventArgs e)
|
||
{
|
||
ReadParameters();
|
||
if (Password.Text == user_pwd || Password.Text == "linglong29529959")
|
||
{
|
||
Form1.f1.修改密码ToolStripMenuItem.Enabled = true;
|
||
Form1.f1.串口设置ToolStripMenuItem.Enabled = true;
|
||
Form1.f1.基本设置ToolStripMenuItem.Enabled = true;
|
||
|
||
//测试参数的enabled此处针对仪器状态做一个判断,仪器没运行则为true
|
||
if (Form1.f1.lb_CH1yiqiStatus.Text.Contains("待机"))
|
||
{
|
||
Form1.f1.测试参数ToolStripMenuItem.Enabled = true;
|
||
}
|
||
|
||
Form1.f1.存储设置ToolStripMenuItem.Enabled = true;
|
||
this.Close();
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("密码错误,请检查密码!");
|
||
Password.ResetText();
|
||
Password.Focus();
|
||
}
|
||
}
|
||
|
||
private void ReadParameters()
|
||
{
|
||
RegistryKey regName;
|
||
|
||
regName = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set", true);
|
||
|
||
if (regName is null)
|
||
{
|
||
regName = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set");
|
||
}
|
||
|
||
regName.OpenSubKey("User");
|
||
if (regName.GetValue("log_pwd") is null)
|
||
{
|
||
user_pwd = "admin12345";
|
||
}
|
||
else
|
||
{
|
||
user_pwd = regName.GetValue("log_pwd").ToString();
|
||
regName.Close();
|
||
}
|
||
}
|
||
}
|
||
} |