0

I am using SHGetSpecialFolderPath to retrieve some Windows special folders with Delphi 7. Here is some code sample:

const
  CSIDL_DESKTOP    = $0000;
  CSIDL_PERSONAL   = $0005;
  CSIDL_MYPICTURES = $0027;
  CSIDL_MYMUSIC    = $000d;
  CSIDL_MYVIDEO    = $000e;
  CSIDL_WINDOWS    = $0024;
  CSIDL_SYSTEM     = $0025;

function GetSpecialFolderPath(Folder: Integer; ForceDir: Boolean): string;
// Uses ShlObj
var
  Path: array [0..255] of char;
begin
  SHGetSpecialFolderPath(0, @Path[0], Folder, ForceDir);
  Result := Path;
end;

edtFolder.Text := GetSpecialFolderPath(CSIDL_DESKTOP, False);

How can I get the "Downloads" folder with this approach?

Kromster
  • 7,181
  • 7
  • 63
  • 111
Guybrush
  • 1,575
  • 2
  • 27
  • 51
  • Have you read the documentation? https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx – Jerry Dodge Feb 25 '15 at 03:52

1 Answers1

7

You cannot get that directory with that API. It predates any OS-designated download folder.

You'll need to use the newer notion of "known folders" with the flag FOLDERID_Downloads instead. How to do that has already been answered elsewhere on Stack Overflow.

Community
  • 1
  • 1
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467