Shell Functions


ExpandEnvironmentStringsForUser Function

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

Syntax

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

Parameters

hToken
[in] 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] Pointer to the null-terminated source string to be expanded.
lpDest
[out] Pointer to a buffer that receives the expanded strings.
dwSize
[in] Specifies the size of the lpDest buffer, in TCHARs.

Return Value

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

Function Information

Minimum DLL VersionUserenv.dll
Custom ImplementationNo
HeaderUserenv.h
Import libraryUserenv.lib
Minimum operating systems Windows 2000 Professional, Windows 2000 Server
UnicodeImplemented as ANSI and Unicode versions.

See Also

Tags :


Page view tracker