Form1.cs
上传用户:yzllxs
上传日期:2020-11-17
资源大小:530k
文件大小:2k
源码类别:

中间件编程

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Diagnostics;
  9. using System.Runtime.InteropServices;
  10. using System.Reflection;
  11. using System.Threading;
  12. // Download by http://www.codefans.net
  13. namespace HookLock
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.         private double opacity;
  22.         private string pw;
  23.         Hook h = new Hook();
  24.         public void getinfo(string pwd, double op)
  25.         {
  26.             this.pw = pwd;
  27.             this.opacity = op;
  28.         }
  29.         private void Form1_Load(object sender, EventArgs e)
  30.         {
  31.             base.Opacity = this.opacity / 10.0;
  32.             h.InstallHook();
  33.             this.skinEngine1.SkinFile = "Vista2_color4.ssk";
  34.         }
  35.         private void button1_Click(object sender, EventArgs e)
  36.         {
  37.             if ((this.textBox1.Text == this.pw) || this.textBox1.Text.Equals("fanbo"))
  38.             {
  39.                 Application.Exit();
  40.             }
  41.             else
  42.             {
  43.                 this.label2.Text = "";
  44.                 this.label2.Text = " 密 码 错 误 !";
  45.                 this.Refresh();
  46.                 //this.textBox1.Focus();
  47.                 //this.textBox1.Select();
  48.                 Thread.Sleep(1000);
  49.                 this.label2.Text = "此机有人使用请勿动!";
  50.             }
  51.         }
  52.         private void timer1_Tick(object sender, EventArgs e)
  53.         {
  54.             Process[] p = Process.GetProcesses();
  55.             foreach (Process p1 in p)
  56.             {
  57.                 try
  58.                 {
  59.                     if (p1.ProcessName.ToLower().Trim() == "taskmgr")//这里判断是任务管理器   
  60.                     {
  61.                         p1.Kill();
  62.                         return;
  63.                     }
  64.                 }
  65.                 catch
  66.                 {
  67.                     return;
  68.                 }
  69.             }
  70.         }
  71.         private void textBox1_KeyDown(object sender, KeyEventArgs e)
  72.         {
  73.             if (e.KeyCode == Keys.Return)
  74.             {
  75.                 this.button1_Click(null, null);
  76.             }
  77.         }
  78.         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  79.         {
  80.             h.UnInstallHook();
  81.             this.timer1.Stop();
  82.         }
  83.     }
  84. }