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


        

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

     /// <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);
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM