GetAppContainerFolderPath function (userenv.h)

Gets the path of the local app data folder for the specified app container.


USERENVAPI HRESULT GetAppContainerFolderPath(
  [in]  PCWSTR pszAppContainerSid,
  [out] PWSTR  *ppszPath


[in] pszAppContainerSid

A pointer to the SID of the app container.

[out] ppszPath

The address of a pointer to a string that, when this function returns successfully, receives the path of the local folder. It is the responsibility of the caller to free this string when it is no longer needed by calling the CoTaskMemFree function.

Return value

This function returns an HRESULT code, including but not limited to the following:

Return code Description
The operation completed successfully.
The pszAppContainerSid or ppszPath parameter is NULL.


The path retrieved through this function is the same path that you would get by calling the SHGetKnownFolderPath function with FOLDERID_LocalAppData.

If a thread token is set, this function uses the app container for the current user. If no thread token is set, this function uses the app container associated with the process identity.


Minimum supported client Windows 8 [desktop apps only]
Minimum supported server Windows Server 2012 [desktop apps only]
Target Platform Windows
Header userenv.h
Library Userenv.lib
DLL Userenv.dll

See also