ExpandEnvironmentStringsForUser
TOC
Collapse the table of content
Expand the table of content

ExpandEnvironmentStringsForUser function

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

Syntax


BOOL WINAPI ExpandEnvironmentStringsForUser(
  _In_opt_ HANDLE  hToken,
  _In_     LPCTSTR lpSrc,
  _Out_    LPTSTR  lpDest,
  _In_     DWORD   dwSize
);

Parameters

hToken [in, optional]

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 [in]

Type: LPCTSTR

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

lpDest [out]

Type: LPTSTR

Pointer to a buffer that receives the expanded strings.

dwSize [in]

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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Userenv.h

Library

Userenv.lib

DLL

Userenv.dll

Unicode and ANSI names

ExpandEnvironmentStringsForUserW (Unicode) and ExpandEnvironmentStringsForUserA (ANSI)

See also

User Profiles Overview
User Profiles Reference

 

 

Show:
© 2016 Microsoft