C# 控制系统任务栏的显示与隐藏

 

 

[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd,int nCmdShow);

private const int SW_HIDE = 0;
private const int SW_RESTORE = 9;

 

/// <summary>
/// 方法
/// </summary>
/// <param name="whether">是否显示</param>
public void HideorShow(bool whether)
{
if (whether == false)
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);//隐藏
}
else
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_RESTORE);//显示
}
}

 

posted @ 2022-03-27 12:32  qingningmeng  阅读(333)  评论(0)    收藏  举报