進程:
一個應用程序就是一個進程
開啟某個進程
Process.Start("文件縮寫名");
通過絕對路徑開啟某個進程
Process p = new Process();
p.StartInfo = new ProcessStartInfo("要打開的程序絕對路徑");
p.Start();
獲取全部開啟的進程:
Process.GetProcesses();
殺死進程
對象.Kill();
常用的開啟網頁注冊賬號:
Process.Start("http://.....");
例如:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;namespace WindowsFormsApplication7 {public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){//Process.Start("calc");//Process.Start("notepad");//Process.Start("chrome");Process pro = new Process();ProcessStartInfo psi = new ProcessStartInfo(textBox1.Text);pro.StartInfo = psi;pro.Start();}private void button2_Click(object sender, EventArgs e){openFileDialog1.Filter = "應用程序|*.exe";DialogResult dr= openFileDialog1.ShowDialog();if(dr==DialogResult.OK){textBox1.Text = openFileDialog1.FileName;}}private void button3_Click(object sender, EventArgs e){}private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e){Process.Start("http://www.qq.com");}private void button3_Click_1(object sender, EventArgs e){Process[] proc= Process.GetProcesses();foreach(Process p in proc){//p.Kill();richTextBox1.Text += p.ToString() + "/r";}}} }
?