我怎么可以禁用的C#Windows键? [英] how can I disable windows key in c#?

查看:115
本文介绍了我怎么可以禁用的C#Windows键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以禁用或锁定窗口按钮?


解决方案

  // ********************** ***********************************************
    // [DCOM制作]
    // [版权所有(C)DCOM制作保留所有权利。]
    //>>戴维·安徒生,DCOM制作的礼貌
    // ************ *********************    ///<总结>
    ///有关Windows键的标准个人计算机键盘安全程序
    ///< /总结>
    公共静态类WindowsKey的{
        ///<总结>
        ///禁用Windows键
        ///< /总结>
        ///<&言论GT;可能需要在当前用户注销或重新启动系统< /言论>
        公共静态无效的禁用(){
            关键的RegistryKey = NULL;
            尝试{
                键= Registry.LocalMachine.OpenSubKey(系统\\\\ \\\\ CURRENTCONTROLSET控制\\\\键盘布局,真正的);
                字节[] =二进制新的字节[] {
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    ×03,
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    0×00,
                    0x5B,
                    取0xE0,
                    0×00,
                    0×00,
                    0x5C,
                    取0xE0,
                    0×00,
                    0×00,
                    0×00,
                    为0x00
                };
                key.SetValue(扫描code地图,二进制,RegistryValueKind.Binary);
            }
            赶上(System.Exception的前){
                Debug.Assert的(假的,ex.ToString());
            }
            最后{
                key.Close();
            }
        }        ///<总结>
        ///启用Windows键
        ///< /总结>
        ///<&言论GT;可能需要在当前用户注销或重新启动系统< /言论>
        公共静态无效启用(){
            关键的RegistryKey = NULL;
            尝试{
                键= Registry.LocalMachine.OpenSubKey(系统\\\\ \\\\ CURRENTCONTROLSET控制\\\\键盘布局,真正的);
                key.DeleteValue(扫描code地图,真正的);
            }
            赶上(System.Exception的前){
                Debug.Assert的(假的,ex.ToString());
            }
            最后{
                key.Close();
            }
        }
    }

How can i disable or lock windows button?

解决方案

    // *********************************************************************
    // [DCOM Productions]
    // [Copyright (C) DCOM Productions All rights reserved.]
    //  >> Courtesy of Dave Anderson, DCOM Productions
    // *********************************************************************

    /// <summary>
    /// Security routines related to the Windows Key on a standard personal computer Keyboard
    /// </summary>
    public static class WindowsKey {
        /// <summary>
        /// Disables the Windows Key
        /// </summary>
        /// <remarks>May require the current user to logoff or restart the system</remarks>
        public static void Disable() {
            RegistryKey key = null;
            try {
                key = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Keyboard Layout", true);
                byte[] binary = new byte[] { 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x03, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x5B, 
                    0xE0, 
                    0x00, 
                    0x00, 
                    0x5C, 
                    0xE0, 
                    0x00, 
                    0x00, 
                    0x00, 
                    0x00 
                };
                key.SetValue("Scancode Map", binary, RegistryValueKind.Binary);
            }
            catch (System.Exception ex) {
                Debug.Assert(false, ex.ToString());
            }
            finally {
                key.Close();
            }
        }

        /// <summary>
        /// Enables the Windows Key
        /// </summary>
        /// <remarks>May require the current user to logoff or restart the system</remarks>
        public static void Enable() {
            RegistryKey key = null;
            try {
                key = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\Control\\Keyboard Layout", true);
                key.DeleteValue("Scancode Map", true);
            }
            catch (System.Exception ex) {
                Debug.Assert(false, ex.ToString());
            }
            finally {
                key.Close();
            }
        }
    }

这篇关于我怎么可以禁用的C#Windows键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆