GetUserProfileDirectory function
Applies to: desktop apps only
Retrieves the path to the root directory of the specified user's profile.
Syntax
BOOL WINAPI GetUserProfileDirectory( __in HANDLE hToken, __out_opt LPTSTR lpProfileDir, __inout LPDWORD lpcchSize );
Parameters
- hToken [in]
-
Type: HANDLE
A token for the user, which is returned by the LogonUser, CreateRestrictedToken, DuplicateToken, OpenProcessToken, or OpenThreadToken function. The token must have TOKEN_QUERY access. For more information, see Access Rights for Access-Token Objects.
- lpProfileDir [out, optional]
-
Type: LPTSTR
A pointer to a buffer that, when this function returns successfully, receives the path to the specified user's profile directory. Set this value to NULL to determine the required size of the buffer.
- lpcchSize [in, out]
-
Type: LPDWORD
Specifies the size of the lpProfileDir buffer, in TCHARs.
If the buffer specified by lpProfileDir is not large enough or lpProfileDir is NULL, the function fails and this parameter receives the necessary buffer size, including the terminating null character.
Return value
Type: BOOL
TRUE if successful; otherwise, FALSE. To get extended error information, call GetLastError.
Remarks
The following is an example of the path returned by GetUserProfileDirectory in Windows XP:
C:\Documents and Settings\Joe
The following is an example of the path returned by GetUserProfileDirectory in Windows 7:
C:\Users\Joe
To obtain the paths of subdirectories of this directory, use the SHGetFolderPath (Windows XP and earlier) or SHGetKnownFolderPath (Windows Vista) function.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | GetUserProfileDirectoryW (Unicode) and GetUserProfileDirectoryA (ANSI) |
See also
- User Profiles Overview
- User Profiles Reference
- GetAllUsersProfileDirectory
- GetDefaultUserProfileDirectory
- GetProfilesDirectory
Send comments about this topic to Microsoft
Build date: 3/7/2012