PathUnExpandEnvStringsA function

Replaces certain folder names in a fully qualified path with their associated environment string.

Syntax

BOOL PathUnExpandEnvStringsA(
  LPCSTR pszPath,
  LPSTR  pszBuf,
  UINT   cchBuf
);

Parameters

pszPath

Type: LPCTSTR

A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to be unexpanded.

pszBuf

Type: LPTSTR

A pointer to a buffer that, when this method returns successfully, receives the unexpanded string. The size of this buffer must be set to MAX_PATH to ensure that it is large enough to hold the returned string.

cchBuf

Type: UINT

The size, in characters, in the pszBuf buffer.

Return Value

Type: BOOL

Returns TRUE if successful; otherwise, FALSE.

Remarks

The following folder paths are replaced by their equivalent environment string.

Folder Environment String
The All Users profile folder %ALLUSERSPROFILE%
The current user's application data folder (Windows Vista and later only). %APPDATA%
The system name %COMPUTERNAME%
The Program Files folder %ProgramFiles%
The system root folder %SystemRoot%
The system drive letter %SystemDrive%
The current user's profile folder %USERPROFILE%
 
Note  %APPDATA% and %USERPROFILE% are relative to the user making the call. This function does not work if the user is being impersonated from a service. For further discussion of access control issues, see Access Control.
 
The environment variables listed in the above table might not all be set on all systems. If an environment variable is not set, it is not unexpanded.

Requirements

   
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 5.0 or later)

See Also

DoEnvironmentSubst