Platform SDK: DLLs, Processes, and Threads |
The SetEnvironmentVariable function sets the value of an environment variable for the current process.
BOOL SetEnvironmentVariable( LPCTSTR lpName, // environment variable name LPCTSTR lpValue // new value for variable );
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
This function has no effect on the system environment variables or the environment variables of other processes.
To add or modify system environment variables, the user selects System from the Control Panel, then selects the Environment tab. The user can also add or modify environment variables at a command prompt using the set command. Environment variables created with the set command apply only to the command window in which they are set, and to its child processes. For more information, type set /? at a command prompt.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Processes and Threads Overview, Process and Thread Functions, GetEnvironmentVariable