问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Runtime.InteropServices;usingMicrosoft.Win32;usingSystem.Diagnostics;namespaceWorkHelper{classSysHook{[DllImport("user32")]publicstaticexternboolBlockInput(boolisBlock);[DllImport(@"native.dll",EntryPoint="FuckSysKey")]privateexternstaticboolFuckSysKey(boolenAble);publicvoidBlockKeyAndMouse(boolb){BlockInput(b);FuckSysKey(b);//锁定ctrl+alt+del}publicdelegateintHookProc(intnCode,intwParam,IntPtrlParam);staticinthHook=0;publicconstintWH_KEYBOARD_LL=13;//LowLevel键盘截获,如果是WH_KEYBOARD=2,并不能对系统键盘截取,AcrobatReader会在你截取之前获得键盘。HookProcKeyBoardHookProcedure;//键盘Hook结构函数[StructLayout(LayoutKind.Sequential)]publicclassKeyBoardHookStruct{publicintvkCode;publicintscanCode;publicintflags;publicinttime;publicintdwExtraInfo;}#regionDllImport//设置钩子[DllImport("user32.dll")]publicstaticexternintSetWindowsHookEx(intidHook,HookProclpfn,IntPtrhInstance,intthreadId);[DllImport("user32.dll",CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]//抽掉钩子publicstaticexternboolUnhookWindowsHookEx(intidHook);[DllImport("user32.dll")]//调用下一个钩子publicstaticexternintCallNextHookEx(intidHook,intnCode,intwParam,IntPtrlParam);[DllImport("kernel32.dll")]publicstaticexternintGetCurrentThreadId();[DllImport("kernel32.dll")]publicstaticexternIntPtrGetModuleHandle(stringname);publicvoidHook_Start(){//安装键盘钩子if(hHook==0){KeyBoardHookProcedure=newHookProc(KeyBoardHookProc);//hHook=SetWindowsHookEx(2,//KeyBoardHookProcedure,//GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName),GetCurrentThreadId());hHook=SetWindowsHookEx(WH_KEYBOARD_LL,KeyBoardHookProcedure,GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName),0);//如果设置钩子失败.if(hHook==0){Hook_Clear();//thrownewException("设置Hook失败!");}}}//取消钩子事件publicvoidHook_Clear(){boolretKeyboard=true;if(hHook!=0){retKeyboard=UnhookWindowsHookEx(hHook);hHook=0;}//如果去掉钩子失败.if(!retKeyboard)thrownewException("UnhookWindowsHookExfailed.");}//这里可以添加自己想要的信息处理publicstaticintKeyBoardHookProc(intnCode,intwParam,IntPtrlParam){if(nCode>=0){KeyBoardHookStructkbh=(KeyBoardHookStruct)Marshal.PtrToStructure(lParam,typeof(KeyBoardHookStruct));//MessageBox.Show(kbh.vkCode.ToString());if(kbh.vkCode!=32){return1;}}returnCallNextHookEx(hHook,nCode,wParam,lParam);}#endregion}}下面用窗体调用,初始化对象SysHookh=newSysHook();h.Hook_Start();//锁定键盘h.Hook_Clear();//解锁h.BlockKeyAndMouse(true);//锁定键盘和鼠标,包括任务管理器热键
解决方案
解决方案二:
锁定ctrl+alt+delete程序,运行时出错。显示:无法加载“native.dll”:找不到指定的模块(异常来自HRESULT:0x8007007E)本机没有native.dll,网上找不到该名称的文件下载,请问是怎么回事呢?如果是有该文件下载的,请直接给出链接。如果是程序本身问题,请给出修改后程序。如果有其他锁住ctrl+alt+delete方法,请给出程序(越详细越好)感谢各位大虾啊!!小弟急用!!!!
解决方案三:
引用1楼的回复:
锁定ctrl+alt+delete程序,运行时出错。显示:无法加载“native.dll”:找不到指定的模块(异常来自HRESULT:0x8007007E)本机没有native.dll,网上找不到该名称的文件下载,请问是怎么回事呢?如果是有该文件下载的,请直接给出链接。如果是程序本身问题,请给出修改后程序。如果有其他锁住ctrl+alt+delete方法,请给出程序(越详细越……
哥儿们儿,这个问题解决没有?