Pascal Scripting: GetShellFolderByCSIDL

Inno Setup

Pascal Scripting: GetShellFolderByCSIDL

Prototype:

function GetShellFolderByCSIDL(const Folder: Integer; const Create: Boolean): String;

Description:

Gets the path of the specified shell folder. Folder specifies the value of a CSIDL constant (a complete list of which can be found in ShlObj.h). If Create is True, the folder will be created if it does not exist. On failure, an empty string is returned.

Remarks:

It is recommended that you always specify True in the Create parameter. Otherwise, the function may fail if the CSIDL value is valid but the directory does not currently exist. (This is a Windows issue.)

Example:
const
  CSIDL_MYPICTURES = $0027;

...

var
  Path: String;
begin
  Path := GetShellFolderByCSIDL(CSIDL_MYPICTURES, True);
  if Path <> '' then
  begin
    MsgBox('My Pictures path = ' + Path, mbInformation, MB_OK);
  end
  else
  begin
    // handle failure
  end;
end;