zoukankan      html  css  js  c++  java
  • 杀线程的代码(转自CSDNcyfboy)

    private void KillProcess(string processName)
            
    {
                System.Diagnostics.Process myproc 
    = new System.Diagnostics.Process();
                
    //得到所有打开的进程
                try
                
    {
                    
    foreach (Process thisproc in Process.GetProcessesByName(processName))
                    
    {
                        
    if (!thisproc.CloseMainWindow())
                        
    {
                            thisproc.Kill();
                        }
                        
                    }

                }

                
    catch (Exception Exc)
                
    {
                    MessageBox.Show(Exc.ToString());
                }

            }


            
    private void Form1_Load(object sender, EventArgs e)
            
    {
                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);
                    
    //this.listBox1.Items.Add(tempName);
                    if (tempName == "newfax")
                    
    {
                        KillProcess(tempName);
                    }

                }

            }


  • 相关阅读:
    CSS基本知识(慕课网)
    html基本标签(慕课网)
    我为什么要写博客
    Android项目实战(三十二):圆角对话框Dialog
    02-05 scikit-learn库之线性回归
    02-36 支持向量回归
    02-25 scikit-learn库之决策树
    02-29 朴素贝叶斯(垃圾邮件分类)
    C-02 推荐系统
    05-02 特征选择
  • 原文地址:https://www.cnblogs.com/Magicsky/p/525312.html
Copyright © 2011-2022 走看看