WinForms 中怎样禁用ALT+F4快捷键

来源:百度知道 编辑:UC知道 时间:2024/07/02 10:24:20
近来老师突然发难,让我做一个锁屏程序.我晕,晓就晓不得工做原理,但还是接下来硬着头皮做.但是做了一半就出问题了.由于系统自带一些快捷键,我做的锁屏程序,别人一个ALT+F4就给我关了.有没有什么方法可以禁用WIN快捷键啊,只是在程序运行时不能用,退出后恢复原状.
(都说具体点,最好弄点源码来,我是新鸟,谢谢各位了)

我用的是全局键盘钩子。这个程序可以屏蔽win和alt+f4但是不能屏蔽ctrl+alt+del。我一直在找屏蔽ctrl+alt+del的方法希望会的人指点一下。用了
form_load事件和Form1_FormClosing事件
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 System.Reflection;

namespace WindowsApplication10
{
public partial class Form1 : Form
{
// 安装钩子
[DllImport("user32.dll")]
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
// 卸载钩子
[DllImport("user32.dll")]
public static extern bool UnhookWindowsHookEx(int idHook);
// 继续下一个钩子
[DllImport("user32.dll")]
public static extern int CallNextHookEx(int idHook, int nCode, Int32 wParam, IntPtr l