GetAllUsersProfileDirectoryA function (userenv.h)

Retrieves the path to the root of the directory that contains program data shared by all users.


USERENVAPI BOOL GetAllUsersProfileDirectoryA(
  [out, optional] LPSTR   lpProfileDir,
  [in, out]       LPDWORD lpcchSize


[out, optional] lpProfileDir


A pointer to a buffer that, when this function returns successfully, receives the path. Set this value to NULL to determine the required size of the buffer, including the terminating null character.

[in, out] lpcchSize


A pointer to 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.


The following is an example of the path returned by GetAllUsersProfileDirectory in Windows XP:

C:\Documents and Settings\All Users

The following is an example of the path returned by GetAllUsersProfileDirectory in Windows 7:


To obtain the paths of subdirectories of this directory, use the SHGetFolderPath (Windows XP and earlier) or SHGetKnownFolderPath (Windows Vista) function.


The userenv.h header defines GetAllUsersProfileDirectory as an alias which 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 not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


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

See also




User Profiles Overview

User Profiles Reference