Agostino
11-11-2005, 01:53 AM
How do I set a system environment variable programmatically?
Is there any api call?
Thanks
Agostino
Joe Richards [MVP]
11-11-2005, 02:45 AM
Is this what you are looking for?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setenvironmentvariable.asp
--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Agostino wrote:
> How do I set a system environment variable programmatically?
> Is there any api call?
> Thanks
> Agostino
>
>
>
Joe Richards [MVP]
11-11-2005, 02:45 AM
Is this what you are looking for?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setenvironmentvariable.asp
--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Agostino wrote:
> How do I set a system environment variable programmatically?
> Is there any api call?
> Thanks
> Agostino
>
>
>
Joe Richards [MVP]
11-11-2005, 02:45 AM
Is this what you are looking for?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setenvironmentvariable.asp
--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Agostino wrote:
> How do I set a system environment variable programmatically?
> Is there any api call?
> Thanks
> Agostino
>
>
>
Gary Chanson
11-11-2005, 05:37 AM
"Agostino" <agostino_sclauzero@hotmail.com> wrote in message
news:OBNcILm5FHA.2628@TK2MSFTNGP11.phx.gbl...
> How do I set a system environment variable programmatically?
> Is there any api call?
If you're trying to set a system environment variable for all programs,
you can't use SetEnvironmentVariable but need to set a value under the key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment where the name of the value is the name of the variable
and the data is a REG_EXPAND_SZ string (if you make it REG_SZ, environment
variables within it may not be properly expanded).
For completeness, environment variables for the current user are contained
in the key HKEY_CURRENT_USER\Environment.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gchanson@mvps.org
Gary Chanson
11-11-2005, 05:37 AM
"Agostino" <agostino_sclauzero@hotmail.com> wrote in message
news:OBNcILm5FHA.2628@TK2MSFTNGP11.phx.gbl...
> How do I set a system environment variable programmatically?
> Is there any api call?
If you're trying to set a system environment variable for all programs,
you can't use SetEnvironmentVariable but need to set a value under the key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment where the name of the value is the name of the variable
and the data is a REG_EXPAND_SZ string (if you make it REG_SZ, environment
variables within it may not be properly expanded).
For completeness, environment variables for the current user are contained
in the key HKEY_CURRENT_USER\Environment.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gchanson@mvps.org
Gary Chanson
11-11-2005, 05:37 AM
"Agostino" <agostino_sclauzero@hotmail.com> wrote in message
news:OBNcILm5FHA.2628@TK2MSFTNGP11.phx.gbl...
> How do I set a system environment variable programmatically?
> Is there any api call?
If you're trying to set a system environment variable for all programs,
you can't use SetEnvironmentVariable but need to set a value under the key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment where the name of the value is the name of the variable
and the data is a REG_EXPAND_SZ string (if you make it REG_SZ, environment
variables within it may not be properly expanded).
For completeness, environment variables for the current user are contained
in the key HKEY_CURRENT_USER\Environment.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gchanson@mvps.org