今天来讲讲如何实现C#锁屏
界面设计
(注意添加两个计时器)
核心代码
Program.cs
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ks());//重点,吧Form1改成ks
}
}
ks.cs
public partial class ks : Form
{
public ks()
{
InitializeComponent();
}
public static string mm = "";
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
MessageBox.Show("请输入密码");
return;
}
mm = textBox1.Text;
Form1 form1 = new Form1();
form1.Show();
this.Hide();
}
private void ks_Load(object sender, EventArgs e)
{