C# Winform 隐藏/显示任务栏

引用空间
using System.Runtime.InteropServices;


          private const int SWP_HIDEWINDOW = 0x80;
          private const int SWP_SHOWWINDOW = 0x40;


          [DllImport("user32.dll")]
          public static extern bool SetWindowPos(
           int hWnd,                           //   handle   to   window     
           int hWndInsertAfter,     //   placement-order   handle     
           short X,                                   //   horizontal   position     
           short Y,                                   //   vertical   position     
           short cx,                                 //   width     
           short cy,                                 //   height     
           uint uFlags                         //   window-positioning   options     
           );


          [DllImport("user32.dll")]
          public static extern int FindWindow(
           string lpClassName,     //   class   name     
           string lpWindowName     //   window   name     
           );   
           
           
           
显示任务栏
   int TaskBarHwnd = FindWindow("Shell_traywnd", null);
   SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);     
           
隐藏任务栏 
   int TaskBarHwnd = FindWindow("Shell_traywnd", null);
   SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);  







你可能感兴趣的:(Web/桌面/系统研发)