时间:2020-10-27 15:52:03 | 栏目:.NET代码 | 点击:次
1.导入System.Runtime.InteropServices命名空间。
2.API函数ShowWindow()能够控制人和窗体的现实状态,其声明格式如下:
3.API函数FindWindow()可用于返回任务栏所在窗体类“Shell_TrayWnd”句柄,其声明格式如下:
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd,int nCmdShow);
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName,string lpWindowName);
private void button1_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd",null),SW_HIDE);
//YinYiNiao's Blog
}
private void button2_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd",null),SW_RESTORE);
}