The ExpandEnvironmentStrings function expands environment-variable strings and replaces them with their defined values.
DWORD ExpandEnvironmentStrings(
LPCTSTR lpSrc, // pointer to string with environment variables
LPTSTR lpDst, // pointer to string with expanded environment
// variables
DWORD nSize // maximum characters in expanded string
);
%variableName%
For each such reference, the %variableName% portion is replaced with the current value of that environment variable.
The replacement rules are the same as those used by the command interpreter. Case is ignored when looking up the environment-variable name. If the name is not found, the %variableName% portion is left undisturbed.
If the function succeeds, the return value is the number of bytes (ANSI version) or characters (Unicode version) stored in the destination buffer, including the terminating null character. If the destination buffer is too small to hold the expanded string, the return value is the required buffer size, in bytes or characters.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
System Information Overview, System Information Functions