首页 > 系统服务 > 详细

2017-5-4 进程

时间:2017-05-04 21:07:26      阅读:139      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!