System and Environment Information Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  • Press F5.

Demonstrates

The main form contains one TabControl with several tab pages. Each tab page calls a different group of Environment or SystemInformation members:

  • Properties This tab demonstrates Environment properties.

  • Special folders The code calls the GetNames method on the Environment..::.SpecialFolder to retrieve a list of all the special folder names. This list is used as a data source for the ListBox control.

  • Methods This tab shows results from calling Environment methods, including Exit and ExpandEnvironmentVariables . The string arrays returned by the GetLogicalDrives and GetCommandLineArgs methods are used as data sources to ListBox controls.

  • Environment variables The code calls the GetEnvironmentVariables method. The Keys property of the returned collection is used as the data source for a ListBox control. This tab page also demonstrates retrieving one environment variable by calling the GetEnvironmentVariable method.

  • System information This tab retrieves all the information provided by the SystemInformation.