本文实例讲述了C#获取任务栏显示进程的方法。分享给大家供大家参考。具体实现方法如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | private static void getWindowsInfo() { try { Process[] MyProcesses = Process.GetProcesses(); string [] Minfo = new string [6]; foreach (Process MyProcess in MyProcesses) { if (MyProcess.MainWindowTitle.Length > 0) { Minfo[0] = MyProcess.MainWindowTitle; Minfo[1] = MyProcess.Id.ToString(); Minfo[2] = MyProcess.ProcessName; Minfo[3] = MyProcess.StartTime.ToString(); Console.WriteLine( "标题:" + Minfo[0]); Console.WriteLine( "编号:" + Minfo[1]); Console.WriteLine( "进程:" + Minfo[2]); Console.WriteLine( "开始时间" + Minfo[3]); Console.WriteLine(); } } } catch { } } |
希望本文所述对大家的C#程序设计有所帮助。