关闭一个非本程序打开的窗口可以使用API SendMessage 发送一个 wm_close 信息如何是本程序启动的可以用 .Kill(),比如Process p = new Process();
p.StartInfo.WorkingDirectory = @"c:\";
p.StartInfo.FileName = "ping.exe";
p.StartInfo.Arguments="www.csdn.com";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start ();p.Kill();

解决方案 »

  1.   

    先用API函数Findwindow,得到其他应用程序的句柄,然后...
      

  2.   

    启动一个由用户指定的可执行程序,(在textBox1中指定)
    using System.Threading;
    private void button1_Click(object sender, System.EventArgs e)
    {
    Process p;
    p.StartInfo.FileName=textBox1.Text;
    p.Start();
    int32 ID;
    ID=p.Id;
    }
    关闭一个应用程序,如果已知该进程ID.
    private void button2_Click(object sender, System.EventArgs e)
    {
            Process p;
            p=Process.GetProcessById(ID);
            p.Kill();
    }
    关闭一个应用程序,如果已知该程序名称.
    private void button2_Click(object sender, System.EventArgs e)
    {
            Process[] p;
            p=Process.GetProcessesByName(ApplicationName);
            p[0].Kill();
    }