Processes management (Process Class)

Source: Internet
Author: User

(Process class under the System.Diagnostics namespace)

"1" gets all processes on the local machine

1 progress[] myprogress = progress.getprocesses ();

"2" gets the process of the name specified on the local computer

1 process[] myprocess = Process.getprocessesbyname (" process name ");

Example: 1 process[] myprocess = Process = Process.getprocessbyneme ("notepad++" );

"3" gets all the processes of the remote computer

1 process[] myprocess = process.getprocesses (remotemachinename);

Where remotemachinename can be a remote computer name, or it can be a remote computer IP address

"4" gets the process with the name specified on the remote computer

1 process[] myprocess = Process.getprocessesbyname (ProcessName, remotemachinename);

Where ProcessName is a process name that does not include the. exe or path name

Example:

1 usingSystem;2 usingSystem.Diagnostics;3 4 namespaceprocesslocal5 {6     class Program7     {8         Static voidMain (string[] args)9         {Tenprocess[] Myprocess =process.getprocesses (); OneConsole.Write ("Process Id\t"); AConsole.Write ("process name \ t"); -Console.Write ("physical memory \ t"); -Console.Write ("startup time \ t"); the             //console.write ("File path"); - Console.WriteLine (); -             foreach(Process Pinchmyprocess) -             { +Console.Write (P.id +"\ t"); -Console.Write (P.processname +"\ t"); +Console.Write (string. Format ("{0:###,# #0.00}MB", P.workingset64/1024.0f/1024.0f) +"\ t"); A                 //Some processes cannot get boot time and file name information, so use Try/catch at                 Try -                 { -Console.Write (String.Format ("{0}", P.starttime) +"\ t"); -                     //Console.Write (p.mainmodule.filename + "T"); -                 } -                 Catch in                 { -                     //Console.Write ("\ t"); toConsole.Write ("\ t"); +                 } - Console.WriteLine (); the  *             } $ Panax Notoginseng Console.read (); -         } the     } +}

Processes management (Process Class)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.