c#实现锁屏及禁止键盘和鼠标
2009-05-26 12:19
417 查看
1.要实现锁定系统不让别人用,可以调用系统锁定API函数来实现
//引入API函数
[DllImport("user32 ")]
public static extern bool LockWorkStation();//这个是调用windows的系统锁定
在需要的时候直接写LockWorkStation();就可以啦!不信试试看!
2.API函数锁定键盘及鼠标
[DllImport("user32.dll")]
static extern void BlockInput(bool Block);
需要的时候就直接写:
BlockInput(true);//锁定鼠标及键盘
BlockInput(false);//解除键盘鼠标锁定
但是这种方式还是不能锁定ctrl+alt+delete,也就是还可以打开任务管理器,怎么办呢?
请看下面的方法:
3.屏蔽ctrl+alt+delete
FileStream fs = 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(); //用文件流打开任务管理器应用程序而不关闭文件流就会阻止打开任务管理器
呵呵,大家可以自己试试看,可以在此基础上面再修改增加些其他的东西!
下面给出所有代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
namespace 锁屏
//引入API函数
[DllImport("user32 ")]
public static extern bool LockWorkStation();//这个是调用windows的系统锁定
在需要的时候直接写LockWorkStation();就可以啦!不信试试看!
2.API函数锁定键盘及鼠标
[DllImport("user32.dll")]
static extern void BlockInput(bool Block);
需要的时候就直接写:
BlockInput(true);//锁定鼠标及键盘
BlockInput(false);//解除键盘鼠标锁定
但是这种方式还是不能锁定ctrl+alt+delete,也就是还可以打开任务管理器,怎么办呢?
请看下面的方法:
3.屏蔽ctrl+alt+delete
FileStream fs = 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(); //用文件流打开任务管理器应用程序而不关闭文件流就会阻止打开任务管理器
呵呵,大家可以自己试试看,可以在此基础上面再修改增加些其他的东西!
下面给出所有代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
namespace 锁屏
相关文章推荐
- c#实现锁屏及禁止键盘和鼠标
- c#实现锁屏及禁止键盘和鼠标
- c# 实现锁屏及禁止键盘和鼠标
- c#实现锁屏及禁止键盘和鼠标
- C#钩子实现简单鼠标键盘的监控和屏蔽
- 用C#程序实现键盘和鼠标的模拟
- C#钩子实现简单鼠标键盘的监控和屏蔽
- C#实现可捕获几乎所有键盘鼠标事件的钩子类完整实例
- C#中winform实现自动触发鼠标、键盘事件的方法
- 用C#程序实现键盘和鼠标的模拟
- C#实现鼠标键盘的监控和屏蔽(转)
- C#实现鼠标、键盘钩子
- C#实现图片鼠标拖动和滚动缩放
- 基于C#实现的HOOK键盘钩子实例代码
- Qt 学习(8)Qt Creator中鼠标键盘事件的处理实现自定义鼠标指针(转)
- C# 实现系统热键盘注册的类
- VBA 禁止键盘鼠标输入
- 如何在 Linux 下锁住键盘和鼠标而不锁屏
- C#实现屏幕键盘(软键盘 ScreenKeyboard)
- AJAX实现类似百度的搜索提示,自动补全和键盘、鼠标操作