coredll.dll 是 Windows CE/行動裝置核心 DLL,桌面版 Windows 8 不存在。FindWindow、ShowWindow 位於 user32.dll,所有桌面版 Windows 皆內建。Shell_TrayWnd(主任務列)Shell_SecondaryTrayWnd#include
#include
void HideTaskbar(bool hide) {
HWND hTaskbar = FindWindow(_T("Shell_TrayWnd"), NULL);
if (hTaskbar) {
ShowWindow(hTaskbar, hide ? SW_HIDE : SW_SHOW);
// 強制重繪
RedrawWindow(hTaskbar, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
} else {
std::cerr << "找不到任務列視窗" << std::endl;
}
}
int main() {
HideTaskbar(true); // 隱藏
Sleep(5000);
HideTaskbar(false); // 顯示
return 0;
}
using System;
using System.Runtime.InteropServices;
class TaskbarControl {
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_HIDE = 0;
const int SW_SHOW = 5;
public static void SetVisible(bool visible) {
IntPtr h = FindWindow("Shell_TrayWnd", null);
if (h != IntPtr.Zero) ShowWindow(h, visible ? SW_SHOW : SW_HIDE);
}
}
Shell_SecondaryTrayWnd 逐一處理。ITaskbarList3::SetTabProperties 或應用程式全螢幕模式 (SW_MAXIMIZE + WS_EX_TOPMOST)。SetWindowPos(hWnd, HWND_TOPMOST, 0,0, cx,cy, SWP_SHOWWINDOW) 覆蓋任務列,而非隱藏系統 UI。Windows 8 隱藏任務列使用 user32.dll 的 FindWindow("Shell_TrayWnd") + ShowWindow(SW_HIDE),coredll.dll 無關。注意權限與多螢幕情況,現代 Windows 建議採用全螢幕覆蓋而非隱藏系統元件。