C#隐藏与显示系统任务栏和开始菜单栏按钮


隐藏与显示系统任务栏和开始菜单栏按钮:
直接上代码:
       private const int SW_HIDE = 0;  //隐藏
       private const int SW_RESTORE= 5;  //显示
 
       [DllImportAttribute("user32.dll")]  
       private static extern int FindWindow(string ClassName,string WindowName);
       [DllImport("user32.dll")]  
       private static extern int ShowWindow(int handle,int cmdShow);


      //隐藏
        private void button3_Click(object sender, EventArgs e)  
        {  
            ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);//隐藏系统任务栏
            ShowWindow(FindWindow("Button", null), SW_HIDE);//隐藏系统开始菜单栏按钮
        }  
     //显示
        private void button2_Click(object sender, EventArgs e)  
        {  
            ShowWindow(FindWindow("Shell_TrayWnd", null), SW_RESTORE);//显示系统任务栏
            ShowWindow(FindWindow("Button", null), SW_RESTORE);//显示系统开始菜单栏按钮
        }


说明:
(1)引用了系统API函数,需要引用命名空间
         using System.Runtime.InteropServices;
(2)ShowWindow()参数类型是一些int类型,可以查看MDNS
也可以写成  
         ShowWindow(FindWindow("Shell_TrayWnd", null), 0); 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM