怎么监测IE是否启动了,如果启动了就立刻关闭?给代码。什么方式都行

解决方案 »

  1.   


    using System;
    using System.Diagnostics;
    using System.ComponentModel;namespace MyProcessSample
    {
    /// <summary>
    /// Shell for the sample.
    /// </summary>
    class MyProcess
    {

       

    void BindToRunningProcesses()
    {
    // Get the current process.
    Process currentProcess = Process.GetCurrentProcess();
    // Get all instances of Notepad running on the local
    // computer.
    Process [] localByName = Process.GetProcessesByName("notepad");
    // Get all instances of Notepad running on the specifiec
    // computer.
    // 1. Using the computer alias (do not precede with "\\").
    Process [] remoteByName = Process.GetProcessesByName("notepad", "myComputer");

    // 2. Using an IP address to specify the machineName parameter. 
    Process [] ipByName = Process.GetProcessesByName("notepad", "169.0.0.0");


    // Get all processes running on the local computer.
    Process [] localAll = Process.GetProcesses();
    // Get all processes running on the remote computer.
    Process [] remoteAll = Process.GetProcesses("myComputer");
    // Get a process on the local computer, using the process id.
    Process localById = Process.GetProcessById(1234);
    // Get a process on a remote computer, using the process id.
    Process remoteById = Process.GetProcessById(2345, "myComputer");

    }

    static void Main()
    {            MyProcess myProcess = new MyProcess();
    myProcess.BindToRunningProcesses();         }
    }
    }
      

  2.   

    Process [] localByName = Process.GetProcessesByName("notepad");//根据名称查找
    foreach(Process p in localByName)
    {
    p.Kill();//关闭进程
    }
      

  3.   


    +1  这是关闭IE进程
    LZ如果想要监测的话,,哪还要添加一个timer事件,设置监测的间隔时间...就可以了...timer1.Interval = 3000;  //每3秒钟监测一次        void timer1_Tick(object sender, EventArgs e)
            {
    Process [] localByName = Process.GetProcessesByName("iexplore");//根据名称查找
    foreach(Process p in localByName)
    {
    p.Kill();//关闭进程
    }
            }