Hide
或
Show
全部的
Taskbars
handle
所以只有一个
taskbar
public static class Taskbar
{
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
[DllImport("user32.dll")]
private static extern int FindWindowEx(int parent, int afterWindow, string className, string windowText);
private const int _SW_HIDE = 0;
private const int _SW_SHOW = 1;
/// <summary>
/// Show all taskbars
/// </summary>
public static void ShowAll()
{
int result = 0;
do
{
result = FindWindowEx(0, result, "Shell_TrayWnd", null);
ShowWindow(result, _SW_SHOW);
}
while (result != 0);
}
/// <summary>
/// Hide all taskbars
/// </summary>
public static void HideAll()
{
int result = 0;
do
{
result = FindWindowEx(0, result, "Shell_TrayWnd", null);
ShowWindow(result, _SW_HIDE);
}
while (result != 0);
}
}
我用过这个片段:
https://stackoverflow.com/a/18257222/6229375