C语言 如何禁用 Windows 7 上的开始按钮(而不是任务栏)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4940796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I disable the Start button (but not the Taskbar) on Windows 7?
提问by Josh G.
On Windows XP, it was possible to disable the Start button with the following code:
在 Windows XP 上,可以使用以下代码禁用“开始”按钮:
hTray = FindWindow (TEXT("Shell_TrayWnd"), NULL);
if (hTray)
{
hStartButton = FindWindowEx(hTray, NULL, TEXT("Button"), NULL);
if (hStartButton) ShowWindow(hStartButton, FALSE);
}
For a public-access computer configuration, I need to be able to do this on Windows 7. The Start button must be disabled (not just hidden), and the remainder of the Taskbar must still be visible and usable. Hiding the Taskbar along with the Start button is not an option. Running full-screen is not an option. Using "Start Killer" won't work because it doesn't actually disable the Start button, just hides it (users can still use hotkeys to pull up the Start menu).
对于公共访问计算机配置,我需要能够在 Windows 7 上执行此操作。必须禁用“开始”按钮(不仅仅是隐藏),并且任务栏的其余部分必须仍然可见和可用。隐藏任务栏和开始按钮不是一个选项。全屏运行不是一种选择。使用“Start Killer”将不起作用,因为它实际上并没有禁用“开始”按钮,只是将其隐藏(用户仍然可以使用热键来调出“开始”菜单)。
I have already tried the method that uses FindWindowExwith 0xC017 as its third parameter and then tries to disable that window. It doesn't work. That method only works if the whole Taskbar is disabled first. What I need is a method that onlydisables the Start menu, just like the code I reproduced above does in XP.
我已经尝试过使用FindWindowEx0xC017 作为其第三个参数的方法,然后尝试禁用该窗口。它不起作用。该方法仅在首先禁用整个任务栏时才有效。我需要的是一种只禁用开始菜单的方法,就像我上面复制的代码在 XP 中所做的那样。
Any help is greatly appreciated.
任何帮助是极大的赞赏。
回答by Cody Gray
The "correct" version for Windows 7 is as shown below:
Windows 7 的“正确”版本如下所示:
HWND hStartBtn = FindWindowEx(NULL, NULL, MAKEINTATOM(0xC017), TEXT("Start"));
if (hStartBtn != NULL)
{
ShowWindow(hStartBtn, FALSE);
}
However, this only disables the button, meaning you won't get the glow or other effects by hovering your mouse cursor over it. You can still click the button region on the taskbar to open the menu.Apparently, the click handler is now implemented in the taskbar window itself, not as part of the separate Start button. That's why you have to disable the entiretaskbar first, and consequently why most of the solutions you've found online do precisely that.
但是,这只会禁用按钮,这意味着您不会通过将鼠标光标悬停在其上来获得发光或其他效果。您仍然可以单击任务栏上的按钮区域来打开菜单。显然,单击处理程序现在是在任务栏窗口本身中实现的,而不是作为单独的“开始”按钮的一部分。这就是为什么您必须首先禁用整个任务栏,因此您在网上找到的大多数解决方案都是这样做的。
However, it looks like the "Start Killer"application now has functions to disable the most common hotkeys that trigger the Start menu, namely Ctrl+Escand the
key. You'll find those options by launching the software, right-clicking on its icon in the taskbar, and selecting "Options" from the menu. You can also edit the Registry to disable the Windows key, as described in this knowledge base article. If you wanted to implement this same functionality yourself through code, the only solution would be a low-level keyboard hook that trapped the keypress events that are responsible and discarded them.
但是,看起来“Start Killer”应用程序现在具有禁用触发“开始”菜单的最常见热键的功能,即Ctrl+Esc和
键。您可以通过启动软件、右键单击任务栏中的图标并从菜单中选择“选项”来找到这些选项。您还可以编辑注册表以禁用 Windows 键,如本知识库文章 中所述。如果您想通过代码自己实现相同的功能,唯一的解决方案是使用低级键盘钩子来捕获负责的按键事件并丢弃它们。
Undocumented hacks like this one are given to breaking with newer versions of Windows. I imagine that Raymond Chen would chuckle and say something like "I told you so". Hacking the Windows interface is a fool's errand. Or, as you say several times in the question, "is not an option".
像这样的未记录的黑客被用于打破较新版本的 Windows。我想陈雷蒙会笑着说“我早就告诉过你了”之类的话。入侵 Windows 界面是一件愚蠢的事。或者,正如您在问题中多次说的,“不是一种选择”。
回答by Boofhead
IS there anything in particular about the start menu you need to disable? You may be able to do the same via policy settings or various other file permissions.
您需要禁用的开始菜单有什么特别的吗?您可以通过策略设置或各种其他文件权限来执行相同的操作。
回答by Stefan
Use one of the available group policies listed here.
使用此处列出的可用组策略之一。
You did not mention whyyou want to disable the start button. If you think about what exactly it is that you don't want your users to do instead of telling us the solution you picked for it (i.e., "disable the start button"), you might come up with a much better solution.
您没有提到为什么要禁用开始按钮。如果您考虑一下您不希望您的用户做什么而不是告诉我们您为其选择的解决方案(即“禁用开始按钮”),您可能会想出一个更好的解决方案。
For example, if you want to prevent users from changing certain settings, block that, not the start button! Or if you don't want them to see all the installed apps, hide those apps instead of the start button! Or...
例如,如果您想阻止用户更改某些设置,请阻止该设置,而不是开始按钮!或者,如果您不希望他们看到所有已安装的应用程序,请隐藏这些应用程序而不是开始按钮!或者...
(I hope you see my point here).
(我希望你在这里看到我的观点)。

