zoukankan      html  css  js  c++  java
  • 2017-5-4 进程

    进程:
    一个应用程序就是一个进程
    开启某个进程
    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";
                }
            }
        }
    }
  • 相关阅读:
    ●单例模式
    ●扩展方法
    ●存储过程比sql语句慢
    ●rownum() over()
    ●日期格式化
    ●sql优化
    VS建立Web网站 20141201
    ORM操作(一) 20141128
    流的操作20141104
    控件:菜单、工具栏、状态栏及TreeView的操作 20141103
  • 原文地址:https://www.cnblogs.com/zhengqian/p/6809453.html
Copyright © 2011-2022 走看看