找传奇、传世资源到传世资源站!

C# 电脑挂机锁,锁屏 实例源码下载

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

电脑挂机锁,用于电脑锁屏,可以自己定义图片及图片透明度,设定密码C# 电脑挂机锁,锁屏 实例源码下载 C#语言基础-第1张 C# 电脑挂机锁,锁屏 实例源码下载 C#语言基础-第2张 using System;using System.Windows.Forms;using System.Text;using System.Runtime.InteropServices;using System.Reflection;using System.IO;namespace SystemLock{ public class myHook { private IntPtr pKeyboardHook = IntPtr.Zero;//键盘钩子句柄 public delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam);// 钩子委托声明 //键盘钩子委托实例不能省略变量 private HookProc KeyboardHookProcedure; //底层键盘钩子 public const int idHook = 13; //安装钩子 [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr pInstance, int threadId); //卸载钩子 [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] public static extern bool UnhookWindowsHookEx(IntPtr pHookHandle); //键盘钩子处理函数 private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam) { KeyMSG m = (KeyMSG)Marshal.PtrToStructure(lParam, typeof(KeyMSG)); if (pKeyboardHook != IntPtr.Zero) { switch (((Keys)m.vkCode)) { case Keys.LWin: case Keys.RWin: case Keys.Delete: case Keys.Alt: case Keys.Escape: case Keys.F4: case Keys.Control: case Keys.Tab: return 1; } } return 0; } //安装钩子 public bool InsertHook() { IntPtr pIn = (IntPtr)4194304; if (this.pKeyboardHook == IntPtr.Zero) { this.KeyboardHookProcedure = new HookProc(KeyboardHookProc); this.pKeyboardHook = SetWindowsHookEx(idHook, KeyboardHookProcedure, pIn, 0); if (this.pKeyboardHook == IntPtr.Zero) { this.UnInsertHook(); return false; } } return true; } //卸载钩子 public bool UnInsertHook() { bool result = true; if (this.pKeyboardHook != IntPtr.Zero) { result = (UnhookWindowsHookEx(this.pKeyboardHook) && result); this.pKeyboardHook = IntPtr.Zero; } return result; } [StructLayout(LayoutKind.Sequential)] public struct KeyMSG { public int vkCode; public int scanCode; public int flags; public int time; public int dwExtraInfo; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复