Skip to content

Instantly share code, notes, and snippets.

@auycro
Created June 13, 2014 03:26
Show Gist options
  • Save auycro/468a1bee498a4bd89a7e to your computer and use it in GitHub Desktop.
Save auycro/468a1bee498a4bd89a7e to your computer and use it in GitHub Desktop.
Get Desktop Path #Delphi
uses ShlObj, ComObj, ActiveX;
//GET DESKTOP FOLDERS
function GetSystemPath(Folder: Integer): string;
var
PIDL: PItemIDList;
Path: LPSTR;
AMalloc: IMalloc;
begin
Path := StrAlloc(MAX_PATH);
SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);
if SHGetPathFromIDList(PIDL, Path) then Result := Path;
SHGetMalloc(AMalloc);
AMalloc.Free(PIDL);
StrDispose(Path);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment