HRESULT SHGetFolderPath(<br> HWND hwndOwner,<br> int nFolder,<br> HANDLE hToken,<br> DWORD dwFlags,<br> LPTSTR pszPath<br>);<br>Parameters<br><br>hwndOwner<br>[in] Handle to an owner window. This parameter is typically set to NULL. If it is not NULL, and a dial-up connection needs to be made to access the folder, a user interface (UI) prompt will appear in this window. <br>nFolder<br>[in] A CSIDL value that identifies the folder whose path is to be retrieved. Only real folders are valid. If a virtual folder is specified, this function will fail. You can force creation of a folder with SHGetFolderPath by combining the folder's CSIDL with CSIDL_FLAG_CREATE. <br>hToken<br>[in] <br>An access token that can be used to represent a particular user. For systems earlier than Microsoft&reg; Windows&reg; 2000, it should be set to NULL. For later systems, hToken is usually set to NULL. However, you may need to assign a value to hToken for those folders that can have multiple users but are treated as belonging to a single user. The most commonly used folder of this type is My Documents. <br><br>The caller is responsible for correct impersonation when hToken is non-NULL. It must have appropriate security privileges for the particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further discussion of access control issues.<br><br>Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetFolderPath to find folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special folders such as My Documents and Desktop. Any items added to the Default User folder also appear in any new user account.<br><br>dwFlags<br>[in] Flags to specify which path is to be returned. It is used for cases where the folder associated with a CSIDL may be moved or renamed by the user. <br>SHGFP_TYPE_CURRENT<br>Return the folder's current path.<br>SHGFP_TYPE_DEFAULT<br>Return the folder's default path.<br>pszPath<br>[out] Pointer to a null-terminated string of length MAX_PATH which will receive the path. If an error occurs or S_FALSE is returned, this string will be empty. <br>Return Value<br><br>Returns standard HRESULT codes, including the following:<br><br>S_FALSE SHGetFolderPathA only. The CSIDL in nFolder is valid, but the folder does not exist. Note that the failure code is different for the ANSI and Unicode versions of this function. <br>E_FAIL SHGetFolderPathW only. The CSIDL in nFolder is valid, but the folder does not exist. Note that the failure code is different for the ANSI and Unicode versions of this function. <br>E_INVALIDARG The CSIDL in nFolder is not valid. <br>