• 杀线程的代码(转自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);
                    }

                }

            }


  • 相关阅读:
    解决Android Studio Gradle DSL method not found: 'android()'
    【转】关于ListView中notifyDataSetChanged()刷新数据不更新原因
    设计模式-单例模式
    IE浏览器让DIV居中
    Java通过DOM解析XML
    git 配置文件位置;git配置文件设置
    git config配置
    dos2unix
    文件的编码问题解决
    git diff old mode 100644 new mode 100755
  • 原文地址:https://www.cnblogs.com/Magicsky/p/525312.html
Copyright © 2020-2023  润新知