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);
                    }

                }

            }


  • 相关阅读:
    phpcms新建模板页教程
    Linux方向职业规划
    Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad
    Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence
    ACM hdu 3336 Count the string
    ACM KMP 格式输入导致TLE
    swing JTable 更新数据
    swing JTable
    HashMap 和 HashTable 区别
    Java中next()和nextLine()
  • 原文地址:https://www.cnblogs.com/Magicsky/p/525312.html
Copyright © 2011-2022 走看看