home *** CD-ROM | disk | FTP | other *** search
-
- <!-- #include virtual="/quickstart/howto/include/header.inc" -->
-
- <h4>How Do I...Get information about processes?</h4>
-
- <div class="indent" style="width:660"><font face="Tahoma" size="1">
-
- <p>You can use the Process component to accomplish
- most process management tasks quickly and easily. You can use this component to
- work with processes on either local or remote computers. For example, you can query
- a process for specific types of
- information, including the names of the modules it is loaded into, the time it
- was started, the number of handles it is consuming, and the set of its threads.</p>
-
- <p>This
- sample illustrates how to get a simple information about a process. It's a small console application that can be run from a
- command prompt. Run the sample without any command line arguments and it will
- print its full usage instructions.</p>
-
- <p>For
- example, if you want to enumerate all processes on your machine, run:</p>
-
- </font><font face="Courier New" color="Blue" size="1"><blockquote>
- > PrInfo.exe e
- </blockquote></font><font face="Tahoma" size="1">
-
- <p>If you want to
- show the most common information about a process, run the sample with the
- "p" option with a process id. Remember to substitute a
- real process id for "125".</p>
-
- </font><font face="Courier New" color="Blue" size="1"><blockquote>
- > PrInfo.exe p 125
- </blockquote></font><font face="Tahoma" size="1">
-
- <p>In its simplest form, getting information about a process involves:</p>
-
- <ol>
- <li>Instantiating a Process component and pointing it to a process running on your
- system:
-
- </font><font face="Courier New" color="Blue" size="1"><p>
- Process process = Process.GetProcessById(processid);
- </p></font><font face="Tahoma" size="1">
-
- <li>Reading the desired property of the Process component, for example:
-
- </font><font face="Courier New" color="Blue" size="1"><p>
- Console.WriteLine("Priority: "+ process.PriorityClass.Format());
- </p></font><font face="Tahoma" size="1">
-
- </ol>
-
- </font></div>
-
- <h4>Example</h4>
-
- <p>
- <div class="indent">
- <a target="_blank" href="/quickstart/howto/samples/Services/Process/PrInfo">
- <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
- </a>
- <div class="caption">PrInfo.exe</div><br>
- [<a target="_blank" href="/quickstart/howto/samples/Services/Process/PrInfo">View Sample</a>] |
- [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/Process/PrInfo/PrInfo.src">View Source</a>]<p>
- </div>
-
- <h4>Source Code</h4>
-
- <div class="code">
- <xmp>
- <!-- #include virtual="/quickstart/howto/samples/Services/Process/PrInfo/PrInfo.cs" -->
- </xmp>
- </div>
-
- <!-- #include virtual="/quickstart/howto/include/footer.inc" -->