Group: Shell Functions - Library: shell32
How to get the path to a Special Folder
HRESULT SHGetFolderPath(
HWND hwndOwner,
int nFolder,
HANDLE hToken,
DWORD dwFlags,
LPTSTR pszPath
);
DECLARE SHORT SHGetFolderPath IN shell32;
INTEGER hwndOwner,;
INTEGER nFolder,;
INTEGER hToken,;
INTEGER dwFlags,;
STRING @pszPath
hwndOwner [in] Handle to an owner window. This parameter is typically set to NULL.
nFolder [in] A CSIDL value that identifies the folder whose path is to be retrieved.
hToken [in] An access token that can be used to represent a particular user.
dwFlags [in] Flags to specify which path is to be returned.
pszPath [out] Pointer to a null-terminated string of length MAX_PATH which will receive the path.
Returns standard HRESULT codes, including the following: S_FALSE, E_FAIL, E_INVALIDARG, SUCCESS (0).
CSIDL values provide a unique system-independent way to identify special folders used frequently by applications, but which may not have the same name or location on any given system. For example, the system folder may be "C:\Windows" on one system and "C:\Winnt" on another.
For Windows versions 98, NT4 the SHGetFolderPath is obtained through SHFolder.dll, not through Shell32.dll.
SHFolder.dll continues to be included for backward compatibility, though the function is now implemented in Shell32.dll.
See also: SHGetSpecialFolderLocation, SHGetKnownFolderPath, SHGetPathFromIDList.