Getting the SYSTEM environment variable

From a thread over an internal alias today..

Some have noticed that in V1 we give you access the user’s environment variables… We are fixing it in Whidbey where you can get the user or machine

Environment.GetEnvironmentVariable("TEMP",EnvironmentVariableTarget.Machine)

 

Notice you can do this in V1 with:

                using (RegistryKey environmentKey =

                       Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Control\Session Manager\Environment", false)) {

                   string value = environmentKey.GetValue(variable) as string;

                   return value;

                }

 

Useful?

 

Published 10 December 03 02:53 by BradA
Filed under:

Comments

# David Levine said on December 10, 2003 8:00 PM:
Anything that reduces the amount of code and hides operating system specific details without sacrificing functionality is a good thing. Most people would not have known how to retrieve that data anyway, so that makes it even better.
# dannyR said on December 11, 2003 4:29 PM:
Yes, it is useful. In addition, taking the target as an argument makes it clear to the developer that there is more than one set of environment variables he should consider. It will help devs write less bugs.
New Comments to this post are disabled

Search

Go

This Blog

Syndication

Page view tracker