如何隐藏Windows 7的开始菜单按钮和任务栏——C#版
在网上很容查到如何隐藏任务栏的代码,但是关于如何隐藏开始菜单按钮的却没有效果(说是调用FindWindowEx API,可在Windows 7上貌似没有反应)。后来查看Spy++才发现开始菜单就是窗口。所以只需调用查找和隐藏窗口的API即可。
class Program
{
// 获得窗体句柄
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String className, String captionName);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hwnd, uint nCmdShow);
static void Main(string[] args)
{
// 获得任务栏句柄
var rwl = FindWindow("Shell_TrayWnd", null);
//当nCmdShow=0:隐藏;=1:显示
ShowWindow(rwl, 0);
var rwl2 = FindWindow("Button", null);
ShowWindow(rwl2, 0);
Console.Read();
ShowWindow(rwl2, 1);
ShowWindow(rwl, 1);
}
}