C# Process 进程启动

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace AllProcess
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 进程信息
            //string CurrentProcessName = Process.GetCurrentProcess().ProcessName;
            //Process[] localAll = Process.GetProcesses();
            //Console.WriteLine("进程的个数{0}",localAll.Length);
            //foreach (Process p in localAll)
            //{
                
            //    if (p.ProcessName == "dnlauncher")
            //    {
                   
            //        Console.WriteLine("标题{0}", p.MainWindowHandle);
            //        Console.WriteLine("找到这个进程了{0}",p.ProcessName);
            //        p.CloseMainWindow();
            //    }

            //}
            #endregion

            
            Process myProcess = new Process();
            ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("notepad.exe");
            myProcess.StartInfo = myProcessStartInfo;
            myProcess.Start();
            System.Threading.Thread.Sleep(1000);
            myProcess.Kill();
            Console.ReadKey();
        }
    }
}

posted on 2012-11-27 22:17  R.Ray  阅读(291)  评论(0)    收藏  举报

导航