代码之家  ›  专栏  ›  技术社区  ›  Dominic Jonas

在Windows 8/10中隐藏多个任务栏

c#
  •  0
  • Dominic Jonas  · 技术社区  · 6 年前

    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

    0 回复  |  直到 6 年前