进程

2017-01-12 19:04:18来源:cnblogs.com作者:老乌尼人点击

获取本机上的所有进程

 //“.”符号表示本机 var processes = Process.GetProcesses(".").OrderBy(order => order.Id);

获取特定的进程

 //获取当前进程 var currentProcess = Process.GetCurrentProcess(); //根据Id获取进程 var processById = Process.GetProcessById(4); //根据Name获取进程 Process[] processesByName = Process.GetProcessesByName("svchost");

进程的线程集合

 var currentProcess = Process.GetCurrentProcess(); var threads = currentProcess.Threads; foreach (ProcessThread item in threads) {      Console.WriteLine($"{item.Id}-{item.StartAddress}-{item.StartTime}-{item.ThreadState}"); }

进程中的模块集合

 var currentProcess = Process.GetCurrentProcess(); var modules = currentProcess.Modules; foreach (ProcessModule item in modules) {     Console.WriteLine($"{item.ModuleName}-{item.ModuleMemorySize}-{item.FileName}-{item.EntryPointAddress}-{item.FileVersionInfo}"); }

进程的启动和结束

 //启动进程 var runProcess = Process.Start("mspaint.exe"); var runProcess = Process.Start(new ProcessStartInfo("mspaint.exe")); //杀掉进程 runProcess.Kill();



最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台