Hide Start Orb on Vista / Win 7 in C#(在 C# 中隐藏 Vista/Win 7 上的 Start Orb)
问题描述
在 Vista 和 Windows 7 上隐藏任务栏时,开始按钮(也称为 Start Orb)不会被隐藏.我一直在寻找解决方案,我找到了一个,但它似乎比必要的复杂.这篇 CodeProject 文章 描述了(并包含代码)您枚举所有子项的解决方案包含开始菜单的进程中所有线程的窗口.
When hiding the Task Bar on Vista and Windows 7 the Start Button (also known as the Start Orb) doesn't get hidden. I've been looking for a solution to this and I've found one but it seems more complex than necessary. This CodeProject article describes (and contains code for) a solution where you enumerate all child windows of all threads in the process that contains the start menu.
有没有人找到更简单的解决方案?
Has anyone found a simpler solution?
仅供参考.隐藏任务栏(不隐藏球体)的代码如下.首先进行必要的 Win32 导入和声明.
Just for reference. The code for hiding the Task Bar (without hiding the Orb) is as follows. First do the necessary Win32 imports and declarations.
[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(IntPtr hwnd, int command);
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
然后,在某个方法中,使用正确的参数调用它们
Then, in a method somewhere, call them with the right arguments
IntPtr hwndTaskBar = FindWindow("Shell_TrayWnd", "");
ShowWindow(this.hwndTaskBar, SW_HIDE);
推荐答案
我能够组合出一个不需要所有线程枚举的解决方案.以下是相关部分.
I was able to put together a solution that didn't require all the thread enumeration. Here are the relevant parts.
如果你声明 FindWindowEx
如下
[DllImport("user32.dll")]
private static extern IntPtr FindWindowEx(
IntPtr parentHwnd,
IntPtr childAfterHwnd,
IntPtr className,
string windowText);
然后您可以像这样访问 Start Orb 的窗口句柄:
You can then access the window handle for the Start Orb like this:
IntPtr hwndOrb = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null);
并像这样禁用 Start Orb:
and disable the Start Orb like this:
ShowWindow(hwndOrb, SW_HIDE);
这个方法的关键是我们使用 IntPtr
类型作为 className 变量,而不是 FindWindowEx
函数中的字符串.这允许我们使用这个函数的一部分,它采用 ATOM
类型而不是 string
.我能够从这篇文章中看出要使用的特定 ATOM
位于 0xC017
处:隐藏 Vista Start Orb
The key to this method is that we use the IntPtr
type for the className variable instead of a string in the FindWindowEx
function. This allows us to use the portion of this function that takes an ATOM
type rather than a string
. I was able to discern that the particular ATOM
to use is at 0xC017
from this post:
Hide Vista Start Orb
希望这个简化的版本可以帮助一些人.
Hope this simplified version helps some people.
更新:我创建了这个新的代码项目页面来记录这个过程.
UPDATE: I created this new Code Project Page to document this process.
这篇关于在 C# 中隐藏 Vista/Win 7 上的 Start Orb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C# 中隐藏 Vista/Win 7 上的 Start Orb


- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01