C#自动刷新网址

在界面上添加Label1   textBox1   Button1    Button2    timer1 
并设置timer1.Enable=false  interval可以先设置10000,运行时凭感觉再适当缩小


private void timer1_Tick(object sender, System.EventArgs e)
  {
   KillProcess("IEXPLORE");
   Process.Start("IExplore.exe", textBox1.Text);
   
  }
  private void KillProcess(string processName)
  {
   try
   {
    foreach (Process thisproc in Process.GetProcessesByName(processName))
    {
     if(!thisproc.CloseMainWindow())
     {
      thisproc.Kill();
     }
    }
   }
   catch(Exception Exc)
   {

   }
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
   timer1.Enabled=true;
  }

  private void button2_Click(object sender, System.EventArgs e)
  {
   timer1.Enabled=false;
  }
此程序的一个缺点时当运行它时不能再浏览其他网页

posted on 2006-11-18 23:20  hzman  阅读(567)  评论(0编辑  收藏  举报