5.3. Querying the Environment

Let's implement a small program to query the local machine environment about the user, processes running on the machine, and the logical drives associated with the machine. Our output looks like this:

 Hello, stanley lippman! Your machine PROUST is running Microsoft Windows NT 5.0.0.2195 Service Pack 1 The current process running is 'HelloEnvironment' Startup Path is C:\C#Programs\HelloEnvironment\bin\Debug There are 46 other processes running on PROUST Process Name: Idle has been running for 3 days total: 3.22:59:33.0130432 Machine PROUST Process Statistics Longer than a day: 1 Longer than an hour: 0 Longer than a minute: 12 Less than a minute: 34 The logical drive subdirectory structure: A:\ :: 2 subdirectories. ...

Get C# Primer: A Practical Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.