本人因爲愛好就自己建了個網站,因爲裏面也沒有什麼東西所以訪問的人很少很少好像只有我自己訪問
今天下午瀏覽csdn的時候發現了篇博文,裏面簡簡單單的把代碼一放。。。沒有什麼介紹什麼的。我用了一個小時吧,整理了一下,供大家參考。。
界面就是這樣了,下面放代碼
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
namespace 簡單訪問博客
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
string x = textBox1.Text;
if (x == "")
{
MessageBox.Show("親,網址不能爲空!");
return;
}
xx();
timer1.Enabled = true;
button3.Enabled = false;
button4.Enabled = true;
}
public void xx()
{
string x = textBox1.Text;
Regex reg = new Regex(@",");//網址之間用逗號隔開
string[] r = reg.Split(x);
Process ps = new Process();
ps.StartInfo.FileName = "iexplore.exe";//調用IE
for (int i = 0; i < r.Length; i++)
{
System.Diagnostics.Process.Start("" + r[i] + "");
}
}
private void timer1_Tick(object sender, EventArgs e)
{
xx();
}
private void button4_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
button4.Enabled = false;
button3.Enabled = true;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text == "")
{
MessageBox.Show("設定時間不能爲空");
return;
}
int x = Convert.ToInt32(textBox2.Text) * 1000;
timer1.Interval = x;
}
private void Form1_Load(object sender, EventArgs e)
{
button4.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox3.Text == "")
{
MessageBox.Show("設定時間不能爲空");
return;
}
timer2.Interval = Convert.ToInt32(textBox3.Text) * 60000;
}
private void timer2_Tick(object sender, EventArgs e)
{
Process[] myProcess;
myProcess = Process.GetProcessesByName("iexplore");
foreach (Process instance in myProcess)
{
instance.WaitForExit(3);
instance.CloseMainWindow();
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("iexplore.exe", "http://www.gliii.com");
}
}
}
ok,就是這樣。有興趣的就試試玩吧~
---------------------- ASP.Net+Unity開發、.Net培訓、期待與您交流! ----------------------詳細請查看:www.itheima.com