C#屏蔽Windows快捷键及任务管理器

更新时间:2023-05-27 04:53:01 阅读: 评论:0

读书卡内容怎么写-落实意识形态工作

C#屏蔽Windows快捷键及任务管理器
2023年5月27日发(作者:夏天到了后面补充句子)

#region 屏蔽Windows功能键(快捷键)

public delegate int HookProc(int nCode, int wParam, IntPtr lParam);

private static int hHook = 0;

public const int WH_KEYBOARD_LL = 13;



//LowLevel键盘截获,如果是WH_KEYBOARD=2,并不能对系统键盘截取,会在你截取之前获得键盘。

private static HookProc KeyBoardHookProcedure;

//键盘Hook结构函数

[StructLayout(tial)]

public class KeyBoardHookStruct

{

public int vkCode;

public int scanCode;

public int flags;

public int time;

public int dwExtraInfo;

}



//设置钩子

[DllImport("")]

public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);



[DllImport("", CharSet = , CallingConvention = l)]

//抽掉钩子

public static extern bool UnhookWindowsHookEx(int idHook);



[DllImport("")]

//调用下一个钩子

public static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam);



[DllImport("")]

public static extern int GetCurrentThreadId();



[DllImport("")]

public static extern IntPtr GetModuleHandle(string name);



public static void Hook_Start()

{

// 安装键盘钩子

if (hHook == 0)

{

KeyBoardHookProcedure = new HookProc(KeyBoardHookProc);

hHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyBoardHookProcedure,

GetModuleHandle(rentProcess().Name), 0);

//如果设置钩子失败.

if (hHook == 0)

{

Hook_Clear();

}

}

}



//取消钩子事件

public static void Hook_Clear()

{

bool retKeyboard = true;

if (hHook != 0)

{

retKeyboard = UnhookWindowsHookEx(hHook);

hHook = 0;

}

//如果去掉钩子失败.

if (!retKeyboard) throw new Exception("Hook去除失败");

}



//这里可以添加自己想要的信息处理

private static int KeyBoardHookProc(int nCode, int wParam, IntPtr lParam)

{

if (nCode >= 0)

{

KeyBoardHookStruct kbh = (KeyBoardHookStruct)tructure(lParam, typeof(KeyBoardHookStruct));



if ( == 91) // 截获左win(开始菜单键)

{

return 1;

}



if ( == 92)// 截获右win(开始菜单键)

{

return 1

;

}



if ( == (int) && (int)erKeys == (int)l) //截获Ctrl+Esc

{

return 1;

}



if ( == (int) && (int)erKeys == (int)) //截获Alt+Esc

{

return 1;

}

if ( == (int)Keys.F4 && (int)erKeys == (int)) //截获alt+f4

{

return 1;

}



if ( == (int) && (int)erKeys == (int)) //截获alt+tab

{

return 1;

}



if ( == (int) && (int)erKeys == (int)l + (int)) //截获Ctrl+Shift+Esc

{

return 1;

}



if ( == (int) && (int)erKeys == (int)) //截获alt+空格

{

return 1;

}



if ( == 241) //截获F1

{

return 1;

}



if ((int)erKeys == (int)l + (int) + (int)) //截获Ctrl+Alt+Delete

{

return 1;

}



if ((int)erKeys == (int)l + (int)) //截获Ctrl+Shift

{

return 1;

}



if ( == (int) && (int)erKeys == (int)l + (int)) //截获Ctrl+Alt+空格

{

return 1;

}

}



return CallNextHookEx(hHook, nCode, wParam, lParam);

}



///

/// 开打任务管理器快捷键为Windows底层按键

///


///

public static void TaskMgrLocking(bool bLock)

{

if (bLock)//屏蔽任务管理器、并且不出现windows提示信息“任务管理器已被管理员禁用”

{

Process p = new Process();

gDirectory = derPath();

me = "";

NoWindow = true;

Style = ;

();

}

el//设置任务管理器为可启动状态

{

Process[] p = cess();



foreach (Process p1 in p)

{

try

{



if (r().Trim() == "taskmgr")//这里判断是任务管理器

{

();

RegistryKey r = bKey("SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", true);

ue("DisableTaskmgr", "0"); //设置任务管理器为可启动状态

SubKey("SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem");



}

}

catch

{

return;

}

}



}



}

#endregion



//调用

private void button1_Click(object nder, EventArgs e)

{

//启动钩子,处理钩子事件

Hook_Start();

//屏蔽任务管理器

TaskMgrLocking(true);

}

///

/// 关闭窗口时事件

///


private void Form1_FormClosing(object nder, FormClosingEventArgs e)

{ //注销Id号为100的热键设定

UnregisterHotKey(Handle, 100); //注销Id号为101的热键设定

UnregisterHotKey(Handle, 101); //注销Id号为102的热键设定

UnregisterHotKey(Handle, 102); //注销Id号为103的热键设定

UnregisterHotKey(Handle, 103);

Hook_Clear();

TaskMgrLocking(fal);

}

前厅经理岗位职责-景泰蓝工艺品

C#屏蔽Windows快捷键及任务管理器

本文发布于:2023-05-27 04:53:01,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/zhishi/a/168513438155939.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:C#屏蔽Windows快捷键及任务管理器.doc

本文 PDF 下载地址:C#屏蔽Windows快捷键及任务管理器.pdf

下一篇:返回列表
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 实用文体写作网旗下知识大全大全栏目是一个全百科类宝库! 优秀范文|法律文书|专利查询|