private const int SW_HIDE = 0;
private const int SW_SHOW = 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_SHOW);
ShowWindow(FindWindow("Button", null), SW_SHOW);
}
//全屏
private void button2_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
ShowWindow(FindWindow("Button", null), SW_HIDE);
}
说明:
(1)引用了系统API函数,需要引用命名空间
using System.Runtime.InteropServices;
(2)ShowWindow()参数类型是一些int类型,可以查看MDNS
也可以写成
ShowWindow(FindWindow("Shell_TrayWnd", null), 0);