home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / prinfo.aspx < prev    next >
Encoding:
Text File  |  2000-06-08  |  2.7 KB  |  76 lines

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <h4>How Do I...Get information about processes?</h4>
  5.  
  6. <div class="indent" style="width:660"><font face="Tahoma" size="1">
  7.  
  8. <p>You can use the Process component to accomplish
  9. most process management tasks quickly and easily. You can use this component to
  10. work with processes on either local or remote computers. For example, you can query
  11. a process for specific types of
  12. information, including the names of the modules it is loaded into, the time it
  13. was started, the number of handles it is consuming, and the set of its threads.</p>
  14.  
  15. <p>This
  16. sample illustrates how to get a simple information about a process. It's a small console application that can be run from a
  17. command prompt. Run the sample without any command line arguments and it will
  18. print its full usage instructions.</p>
  19.  
  20. <p>For
  21. example, if you want to enumerate all processes on your machine, run:</p>
  22.  
  23.     </font><font face="Courier New" color="Blue" size="1"><blockquote>
  24.         > PrInfo.exe e 
  25.     </blockquote></font><font face="Tahoma" size="1">
  26.  
  27. <p>If you want to
  28. show the most common information about a process, run the sample with the
  29. "p" option with a process id. Remember to substitute a
  30. real process id for "125".</p>
  31.  
  32.     </font><font face="Courier New" color="Blue" size="1"><blockquote>
  33.         > PrInfo.exe p 125
  34.     </blockquote></font><font face="Tahoma" size="1">
  35.  
  36. <p>In its simplest form, getting information about a process involves:</p>
  37.  
  38. <ol>
  39. <li>Instantiating a Process component and pointing it to a process running on your
  40. system:
  41.  
  42.     </font><font face="Courier New" color="Blue" size="1"><p>
  43.         Process process = Process.GetProcessById(processid);
  44.     </p></font><font face="Tahoma" size="1">
  45.  
  46. <li>Reading the desired property of the Process component, for example:
  47.  
  48.     </font><font face="Courier New" color="Blue" size="1"><p>
  49.         Console.WriteLine("Priority: "+ process.PriorityClass.Format());
  50.     </p></font><font face="Tahoma" size="1">
  51.  
  52. </ol>
  53.  
  54. </font></div>
  55.  
  56. <h4>Example</h4>
  57.  
  58. <p>
  59. <div class="indent">
  60. <a target="_blank" href="/quickstart/howto/samples/Services/Process/PrInfo">
  61. <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
  62. </a>
  63. <div class="caption">PrInfo.exe</div><br>
  64. [<a target="_blank" href="/quickstart/howto/samples/Services/Process/PrInfo">View Sample</a>] | 
  65. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/Process/PrInfo/PrInfo.src">View Source</a>]<p>
  66. </div>
  67.  
  68. <h4>Source Code</h4>
  69.  
  70. <div class="code">
  71. <xmp>
  72. <!-- #include virtual="/quickstart/howto/samples/Services/Process/PrInfo/PrInfo.cs" -->
  73. </xmp>
  74. </div>
  75.  
  76. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->