Platform SDK: DLLs, Processes, and Threads |
The GetEnvironmentVariable function retrieves the value of the specified variable from the environment block of the calling process. The value is in the form of a null-terminated string of characters.
DWORD GetEnvironmentVariable( LPCTSTR lpName, // environment variable name LPTSTR lpBuffer, // buffer for variable value DWORD nSize // size of buffer );
If the function succeeds, the return value is the number of TCHARs stored into the buffer pointed to by lpBuffer, not including the terminating null character.
If the specified environment variable name was not found in the environment block for the current process, the return value is zero.
If the buffer pointed to by lpBuffer is not large enough, the return value is the buffer size, in TCHARs, required to hold the value string and its terminating null character.
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, GetEnvironmentStrings, SetEnvironmentVariable