winform顯示、隱藏任務欄及開始菜單

        

      private const int SW_HIDE = 0; //隱藏
      private const int SW_RESTORE = 9;//顯示ide

     /// <summary>
        /// 獲取窗體的句柄函數
        /// </summary>
        /// <param name="lpClassName">窗口類名</param>
        /// <param name="lpWindowName">窗口標題名</param>
        /// <returns>返回句柄</returns>
        [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        /// <summary>
        /// 顯示任務欄 && 開始菜單
        /// </summary>
        public static void ShowTask()
        {
            //顯示任務欄
            ShowWindow((int)FindWindow("Shell_TrayWnd", null), SW_RESTORE);
            //顯示系統開始菜單欄按鈕
            ShowWindow((int)FindWindow("Button", null), SW_RESTORE);
        }

        /// <summary>
        /// 隱藏任務欄 && 開始菜單
        /// </summary>
        public static void HideTask()
        {
            //隱藏任務欄
            ShowWindow((int)FindWindow("Shell_TrayWnd", null), SW_HIDE);
            //隱藏系統開始菜單欄按鈕
            ShowWindow((int)FindWindow("Button", null), SW_HIDE);
        }
相關文章
相關標籤/搜索