Process and Thread Function ...


SetEnvironmentVariable Function

Sets the contents of the specified environment variable for the current process.

Syntax

C++
BOOL WINAPI SetEnvironmentVariable(
  __in      LPCTSTR lpName,
  __in_opt  LPCTSTR lpValue
);

Parameters

lpName [in]

The name of the environment variable. The operating system creates the environment variable if it does not exist and lpValue is not NULL.

lpValue [in, optional]

The contents of the environment variable. The total size of the environment block for a process may not exceed 32,767 characters. For more information, see Environment Variables.

If this parameter is NULL, the variable is deleted from the current process's environment.

Return Value

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.

Remarks

This function has no effect on the system environment variables or the environment variables of other processes.

Examples

For an example, see Changing Environment Variables.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesSetEnvironmentVariableW (Unicode) and SetEnvironmentVariableA (ANSI)

See Also

Environment Variables
GetEnvironmentVariable

Send comments about this topic to Microsoft

Build date: 10/8/2009

Tags :


Page view tracker