实现效果:
知识运用:
API函数FindWindow和ShowWindow
实现代码:
private const int SW_HIDE = 0; private const int SW_RESTORE = 9; [DllImport("user32.dll")] //寻找窗口列表中第一个符合指定条件的顶级窗口 public static extern int FindWindow(string IpClassName,string IpWindowName); [DllImport("user32.dll")] //控制窗口的可见性 public static extern int ShowWindow(int hwnd,int nCmdShow); private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE); //隐藏任务栏 else ShowWindow(FindWindow("Shell_TrayWnd",null),SW_RESTORE);//显示任务栏 }
原文地址:https://www.cnblogs.com/feiyucha/p/10311251.html
时间: 2024-10-09 05:16:17