ExpandEnvironmentStringsForUserA function

Expands the source string by using the environment block established for the specified user.

Syntax

USERENVAPI BOOL ExpandEnvironmentStringsForUserA(
  HANDLE hToken,
  LPCSTR lpSrc,
  LPSTR  lpDest,
  DWORD  dwSize
);

Parameters

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.

lpSrc

Type: LPCTSTR

Pointer to the null-terminated source string to be expanded.

lpDest

Type: LPTSTR

Pointer to a buffer that receives the expanded strings.

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

Requirements

   
Windows version Windows 2000 Professional [desktop apps only] Windows 2000 Server [desktop apps only]
Target Platform Windows
Header userenv.h
Library Userenv.lib
DLL Userenv.dll

See Also

User Profiles Overview

User Profiles Reference