Set Global EnvironmentVariable?

  • Thread starter Thread starter Dmitri Shvetsov
  • Start date Start date
D

Dmitri Shvetsov

Hi,

Does somebody know how to create a new EnvironmentVariable, not only for a
current session, but a global?

I need to write something like an installation program and I want to add
several global system variables for my application and a database. How can I
do that?

Thanks.

Dmitri S.
 
You can create application variables.

Application["nameOfTheGlobalVariable"] = someObject;

String text = (string)Application["nameOfTheGlobalVariable"]

You can create session variables this way too by using Session[].
 
Dmitri,

In the section of the MSDN documentation titled "Environment Variables"
(located at
http://msdn.microsoft.com/library/d.../en-us/dllproc/base/environment_variables.asp),
it states:

To programmatically add or modify system environment variables, add them to
the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session
Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message.
This allows applications, such as the shell, to pick up your updates.

Hope this helps.
 
Back
Top