ExpandEnvironmentStringsForUserW function (userenv.h)
Expands the source string by using the environment block established for the specified user.
Syntax
USERENVAPI BOOL ExpandEnvironmentStringsForUserW(
[in, optional] HANDLE hToken,
[in] LPCWSTR lpSrc,
[out] LPWSTR lpDest,
[in] DWORD dwSize
);
Parameters
[in, optional] hToken
Type: HANDLE
Token for the user, returned from the LogonUser, CreateRestrictedToken, DuplicateToken, OpenProcessToken, or OpenThreadToken function. The token must have TOKEN_IMPERSONATE and TOKEN_QUERY access. In addition, as of Windows 7 the token must also have TOKEN_DUPLICATE access. For more information, see Access Rights for Access-Token Objects.
If hToken is NULL, the environment block contains system variables only.
[in] lpSrc
Type: LPCTSTR
Pointer to the null-terminated source string to be expanded.
[out] lpDest
Type: LPTSTR
Pointer to a buffer that receives the expanded strings.
[in] dwSize
Type: DWORD
Specifies the size of the lpDest buffer, in TCHARs.
Return value
Type: BOOL
TRUE if successful; otherwise, FALSE. To get extended error information, call GetLastError.
Remarks
The following is an example source string:
%USERPROFILE%\ntuser.dat
When ExpandEnvironmentStringsForUser returns, the destination string expands as follows:
C:\Documents and Settings\UserName\ntuser.dat
Note
The userenv.h header defines ExpandEnvironmentStringsForUser as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | userenv.h |
Library | Userenv.lib |
DLL | Userenv.dll |