如题, 在网上搜了下 在VB中的  Form_Unload 事件下可以用
ShellExecute(Me.hwnd, "open", ntsd, "-c q -pn QQ.exe", vbNullString, SW_SHOWNORMAL)'
实现效果但是在 C#窗体中没有这个事件想问下应该怎么解决?或者还有另外的答案 应该怎么写啊,谢谢大家在百忙中抽空看帖!

解决方案 »

  1.   

     
    private void Form2_FormClosed(object sender, FormClosedEventArgs e)
            { 
                Process[] mProcs = Process.GetProcessesByName("QQ.exe");
                foreach (Process pro in mProcs)
                {
                    pro.Kill();//停止关联进程
                }
            }这种方法我试了 不行的请问下有没有好点的方法啊
      

  2.   

    ShellExecute(this.hwnd, "open", ntsd, "-c q -pn QQ.exe", null, SW_SHOWNORMAL);
      

  3.   

    找到了 这个方法可以用的         private bool closeProc(string ProcName)
            {
                bool result = false;
                System.Collections.ArrayList procList = new System.Collections.ArrayList();
                string tempName = "";
                foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses())
                {
                    tempName = thisProc.ProcessName;
                    procList.Add(tempName);
                    if (tempName == ProcName)
                    {
                        if (!thisProc.CloseMainWindow())
                            thisProc.Kill(); //当发送关闭窗口命令无效时强行结束进程                                 
                        result = true;
                    }
                }
                return result;
            }
    楼上的 分给你吧