日期:2014-05-17 浏览次数:20833 次
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr FindWindow(string strclassName, string strWindowName);
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
IntPtr trayHwnd = FindWindow(null, null);//如果通过窗口类查找目标程序填写第一个参数,如果通过窗口的标题查找程序填写第二个参数,相反另一个不用的参数填写为null
if (trayHwnd != IntPtr.Zero)
{
ShowWindow(trayHwnd, 0);//为0隐藏,为1显示
}
}