Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GetEnvironmentStrings function

Retrieves the environment variables for the current process.

Syntax


LPTCH WINAPI GetEnvironmentStrings(void);

Parameters

This function has no parameters.

Return value

If the function succeeds, the return value is a pointer to the environment block of the current process.

If the function fails, the return value is NULL.

Remarks

The GetEnvironmentStrings function returns a pointer to a block of memory that contains the environment variables of the calling process (both the system and the user environment variables). Each environment block contains the environment variables in the following format:

Var1=Value1\0
Var2=Value2\0
Var3=Value3\0
...
VarN=ValueN\0\0

Treat this memory as read-only; do not modify it directly. To add or change an environment variable, use the GetEnvironmentVariable and SetEnvironmentVariable functions.

When the block returned by GetEnvironmentStrings is no longer needed, it should be freed by calling the FreeEnvironmentStrings function.

Note that the ANSI version of this function, GetEnvironmentStringsA, returns OEM characters.

Examples

For an example, see Changing Environment Variables.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

WinBase.h on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2 (include Windows.h);
Processenv.h on Windows 8 and Windows Server 2012

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

GetEnvironmentStringsW (Unicode) and GetEnvironmentStringsA (ANSI)

See also

Environment Variables
FreeEnvironmentStrings
GetEnvironmentVariable
SetEnvironmentVariable

 

 

Community Additions

Show:
© 2014 Microsoft