Files
LL17-honghai/C-Windows-1/LogOn.cs
2025-11-21 10:50:27 +08:00

70 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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();
}
}
}
}