第一个form 两个输密码的textbox 一个button 点butto就能屏幕锁定
第二个form只有一个text和一个button
但是我按以下的代码只能实现到 待机状态 不是锁屏啊
form1代码:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace locked
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string pwd = "";
private void button1_Click(object sender, EventArgs e)
{
if ((txtpwd1.Text == txtpwd2.Text) && txtpwd1.Text != "")
{
Form2 f2 = new Form2();
pwd = txtpwd1.Text;
this.Hide();
f2.Show();
}
if (txtpwd1.Text == "" || txtpwd2.Text == "")
{
MessageBox.Show("密码不能为空");
txtpwd1.Text = "";
txtpwd2.Text = "";
}
if(txtpwd1.Text!=txtpwd2.Text)
{
MessageBox.Show("两次密码不一致,请重新输入");
txtpwd1.Text = "";
txtpwd2.Text = "";
}
}
}
}form2代码:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace locked
{
public partial class Form2 : Form {
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
if (f1.pwd==txtpwd.Text)
{
LockWorkStation();
this.Dispose();
}
else
{
txtpwd.Text = "密码错误,请重新输入";
}
} private void Form2_Load(object sender, EventArgs e)
{
Location = new Point(0, 0);
Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
this.TopMost = true;
} private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
[DllImport("User32.dll ")] public static extern void LockWorkStation(); }
}
求高手解决啊 form1的密码传不到form2里面啊
第二个form只有一个text和一个button
但是我按以下的代码只能实现到 待机状态 不是锁屏啊
form1代码:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace locked
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string pwd = "";
private void button1_Click(object sender, EventArgs e)
{
if ((txtpwd1.Text == txtpwd2.Text) && txtpwd1.Text != "")
{
Form2 f2 = new Form2();
pwd = txtpwd1.Text;
this.Hide();
f2.Show();
}
if (txtpwd1.Text == "" || txtpwd2.Text == "")
{
MessageBox.Show("密码不能为空");
txtpwd1.Text = "";
txtpwd2.Text = "";
}
if(txtpwd1.Text!=txtpwd2.Text)
{
MessageBox.Show("两次密码不一致,请重新输入");
txtpwd1.Text = "";
txtpwd2.Text = "";
}
}
}
}form2代码:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace locked
{
public partial class Form2 : Form {
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
if (f1.pwd==txtpwd.Text)
{
LockWorkStation();
this.Dispose();
}
else
{
txtpwd.Text = "密码错误,请重新输入";
}
} private void Form2_Load(object sender, EventArgs e)
{
Location = new Point(0, 0);
Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
this.TopMost = true;
} private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
[DllImport("User32.dll ")] public static extern void LockWorkStation(); }
}
求高手解决啊 form1的密码传不到form2里面啊
解决方案 »
- 初学者请教
- 求一 数据邦定方法
- 高手请进,帮我看一下错在那里阿!急急急急!
- 为什么只有在安装有.net开发环境下的机器才能运行程序?奇怪啊!
- 最近公司要装FIREWALL,才注意到好象 C/S 结构的程序不能在INTERNET上使用,但是另一套JAVA SWING的C/S程序却可以运行。
- 请问如何把XmlReader转换为XmlTextReader?
- windows phone 8如何生成appxupload文件
- 我的ContextMenuStrip为什么总是显示在整个屏幕的左上角?
- C# 遠程訪問攝像頭, 并傳回視頻
- 怎么读dataSet里的单条数据?
- Access数据库,TableAdapter配置向导中不能输入@参数
- 高分求各位高手指点!!!急!!!!!!!!!
调试 起来也没用啊
求高手告诉关键代码啊
的时候 建议
Form2 f2 = new Form2(pwd);
在form2的构造函数里面重载
public Form2(string psd)
{
this.pwd = psd
}建议看看窗体传值的资料,有很多种方法
我改了 但是效果是 调出了 windows的那个输入开机密码界面 我想实现用我输入textbox
的密码 来解除屏幕锁定要怎么写代码呢