Function Reference


Retrieves the full path of a known folder identified

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetKnownFolderPath ( $sGUID [, $iFlags = 0 [, $hToken = 0]] )


$sGUID The GUID ($FOLDERID_*) that identifies the standard folders registered with the system.
$iFlags [optional] The flags that specify special retrieval options. This parameter can be one or more of the following values.

Windows 7 or later
$hToken [optional] The access token that represents a particular user. If this parameter is 0, the function requests
the known folder for the current user. Assigning the $hToken parameter a value of (-1) indicates the
Default User. Note that access to the Default User folders requires administrator privileges.

Return Value

Success: The path of the known folder.
Failure: Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.


This function requires Windows Vista or later.

See Also

Search SHGetKnownFolderPath in MSDN Library.


#include <APIShellExConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISYs.au3>

If Number(_WinAPI_GetVersion()) < 6.0 Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')

ConsoleWrite(_WinAPI_ShellGetKnownFolderPath($FOLDERID_SendTo, 0, -1) & @CRLF)
ConsoleWrite(_WinAPI_ShellGetKnownFolderPath($FOLDERID_SendTo) & @CRLF)

Local Const $sFOLDERID_wrong = '{8983036C-27C0-404B-8F08-102D10DCFD75}'
ConsoleWrite('"' & _WinAPI_ShellGetKnownFolderPath($sFOLDERID_wrong) & '" @error = ' & @error & ' @extended = 0x' & Hex(@extended) & @CRLF)