public void btnShow_Click(object sender, System.EventArgs e){
ArrayList procList =new ArrayList();
string tempName="";
int begpos;
int endpos;
  foreach (Process thisProc in System.Diagnostics.Process.GetProcesses()) {
      tempName=thisProc.ToString();
       begpos = tempName.IndexOf("(")+1;
       endpos=  tempName.IndexOf(")");
       tempName=tempName.Substring(begpos,endpos-begpos);
       procList.Add(tempName);
       }

 }
先用这个得到所有的进程,然后找到你想要的那个,然后就Kill吧

解决方案 »

  1.   

    先得到所有的进程,然后杀掉就OK了,使用Process类,如果要远程的话,使用Management登陆,并得到远程的所有服务,然后杀掉!
      

  2.   

    在类体中的最上方声明:
    [DllImport("user32.dll", CharSet=CharSet.Auto)] 
    public static extern int SendMessage(int hWnd, int msg, int wParam, int lparam);
    在函数中,就可以直接用:SendMessage(hwnd1,WM_CLOSE,0,0);
    hwnd1是你用findwindow函数返回的句柄值!wm_close定义在winuser.h里面!
      

  3.   

    谢谢各位!
    另外我还找到了一个办法。
    就是 直接用当前Form的SendMessage方法,
    SendMessage(hNext,0x0010,0,0);//hNext是找到的窗口句柄,0x0010是 WM_CLOSE的值。
      

  4.   

    不好意思,
    其实还是在 form1里面导入了函数SendMessage
    [DllImport("user32.dll", CharSet=CharSet.Auto)] 
    public static extern int SendMessage(int hWnd, int msg, int wParam, int lparam);唉,还郁闷半天呢