码迷,mamicode.com
首页 > 系统相关 > 详细

2017-5-4 进程

时间:2017-05-04 22:02:35      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:obj   get   获取   info   注册账号   dial   cli   strong   lte   

进程:
一个应用程序就是一个进程
开启某个进程
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";
            }
        }
    }
}

 

2017-5-4 进程

标签:obj   get   获取   info   注册账号   dial   cli   strong   lte   

原文地址:http://www.cnblogs.com/zhengqian/p/6809453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!