如何在 Windows 7 上禁用“开始”按钮(但不禁用任务栏)?

发布于 2024-10-16 22:46:47 字数 592 浏览 7 评论 0原文

在 Windows XP 上,可以使用以下代码禁用“开始”按钮:

hTray = FindWindow (TEXT("Shell_TrayWnd"), NULL);
if (hTray)
{
    hStartButton = FindWindowEx(hTray, NULL, TEXT("Button"), NULL);
    if (hStartButton) ShowWindow(hStartButton, FALSE);
}

对于公共访问计算机配置,我需要能够在 Windows 7 上执行此操作。必须禁用“开始”按钮(而不仅仅是隐藏),并且任务栏的其余部分必须仍然可见且可用。隐藏任务栏和“开始”按钮不是一个选项。全屏运行不是一个选项。使用“Start Killer”是行不通的,因为它实际上并没有禁用“开始”按钮,只是隐藏了它(用户仍然可以使用热键来拉出“开始”菜单)。

我已经尝试过使用 FindWindowEx 并将 0xC017 作为其第三个参数的方法,然后尝试禁用该窗口。这不起作用。仅当首先禁用整个任务栏时,该方法才有效。我需要的是一种禁用开始菜单的方法,就像我上面复制的代码在 XP 中所做的那样。

非常感谢任何帮助。

On Windows XP, it was possible to disable the Start button with the following code:

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).

I have already tried the method that uses FindWindowEx with 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 only disables the Start menu, just like the code I reproduced above does in XP.

Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾北清歌寒 2024-10-23 22:46:47

Windows 7 的“正确”版本如下所示:

HWND hStartBtn = FindWindowEx(NULL, NULL, MAKEINTATOM(0xC017), TEXT("Start"));
if (hStartBtn != NULL)
{
    ShowWindow(hStartBtn, FALSE);
}

但是,这只会禁用按钮,这意味着您无法通过悬停鼠标来获得发光或其他效果将光标放在它上面。 您仍然可以单击任务栏上的按钮区域来打开菜单。显然,单击处理程序现在是在任务栏窗口本身中实现的,而不是作为单独的“开始”按钮的一部分。这就是为什么您必须首先禁用整个任务栏,因此您在网上找到的大多数解决方案正是这样做的。

然而,看起来"Start Killer"应用程序现在具有禁用最常见热键的功能触发开始菜单,即 Ctrl+Esc Windows键。您可以通过启动该软件,右键单击任务栏中的图标,然后从菜单中选择“选项”来找到这些选项。您还可以编辑注册表以禁用 Windows 键,如此知识库文章中所述。如果您想通过代码自己实现相同的功能,唯一的解决方案是使用低级键盘挂钩来捕获负责的按键事件并丢弃它们。

像这样的未记录的黑客攻击是为了破坏较新版本的 Windows。我想象 Raymond Chen 会笑着说“我告诉过你了”。侵入 Windows 界面是一件愚蠢的事。或者,正如您在问题中多次说过的那样,“不是一个选择”。

The "correct" version for Windows 7 is as shown below:

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 entire taskbar 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+Esc and the Windowskey. 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.

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".

尛丟丟 2024-10-23 22:46:47

关于开始菜单有什么特别需要禁用的吗?您可以通过策略设置或各种其他文件权限执行相同的操作。

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.

羅雙樹 2024-10-23 22:46:47

使用此处列出的可用组策略之一。

您没有提及为什么要禁用开始按钮。如果您考虑一下您到底不希望用户做什么,而不是告诉我们您为其选择的解决方案(即“禁用开始按钮”),您可能会想出一个更好的解决方案。

例如,如果您想阻止用户更改某些设置,请阻止,而不是开始按钮!
或者,如果您不希望他们看到所有已安装的应用程序,请隐藏这些应用程序而不是开始按钮!
或者......

(我希望你能明白我的观点)。

Use one of the available group policies listed here.

You did not mention why you 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文