如何禁用Windows密钥 [英] How to disable windows key
本文介绍了如何禁用Windows密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
>您好,
我想在c sharp中禁用Windows Key,但我不能。我能够隐藏任务栏和开始菜单,但不能禁用Windows键。
这是我做的代码:
>Hello,
I want to disable the Windows Key in c sharp but I can't. I was able to hide the taskbar and the start menu but not to disable the Windows Key.
Here is the code of what I did:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.Win32;
namespace UserControl
{
class Taskbar
{
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
[DllImport("user32.dll")]
public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle);
[DllImport("user32.dll")]
private static extern int GetDesktopWindow();
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
protected static int Handle
{
get
{
return FindWindow("Shell_TrayWnd", "");
}
}
protected static int HandleOfStartButton
{
get
{
int handleOfDesktop = GetDesktopWindow();
int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0);
return handleOfStartButton;
}
}
public Taskbar()
{
// hide ctor
}
public static void Show()
{
ShowWindow(Handle, SW_SHOW);
ShowWindow(HandleOfStartButton, SW_SHOW);
}
public static void Hide()
{
ShowWindow(Handle, SW_HIDE);
ShowWindow(HandleOfStartButton, SW_HIDE);
}
}
}
我想要的是在这个类中添加Windows Key Disable。如果我关闭应用程序,我必须能够再次启用。
谢谢。
我尝试了什么:
我能够隐藏任务栏和开始菜单但不能禁用Windows Key。
What I want is to add the Windows Key Disable in this class. And I must be able to Enable again if I close the appplication.
Thank you.
What I have tried:
I was able to hide the taskbar and the start menu but not to disable the Windows Key.
推荐答案
有关各种技术,请参阅StackOverflow上的此主题:[ ^ ]
但是......
这种任务经常在kiosk模式下使用Windows,或者驱动销售点ui或者网吧ui时发现,我建议你研究那些,如果你的目标是真正限制用户可以用键盘(和/或鼠标)做什么。
但是,请考虑禁用Windows键标准行为(或alt-tab键组合默认值)行为等)可能会让一些用户感到困惑......和/或生气。
您是否打开并阅读了此页面上显示的相关问题链接?
See this thread on StackOverflow for a variety of techniques: [^]
However ...
This kind of task is often found when using Windows in "kiosk" mode, or to drive a point-of-sale ui, or internet-cafe ui, and I suggest you research those if your goal is to really limit what the user can do with keyboard (and/or mouse).
But, consider that disabling the Windows key standard behavior (or the alt-tab key-combination default behavior, etc.) is probably going to make some users confused ... and/or angry.
Have you opened and read the links to "related questions" that appear on this page ?
这篇关于如何禁用Windows密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文