Zum beispiel so (Kopie, nicht mein Code)
Delphi-Quellcode:
uses
ShlObj,
ActiveX, ShellApi;
{ ... }
function GetSpecialFolder(
const AFolder: Integer):
String;
var
ItemIDList: PItemIDList;
hPath: PChar;
ShellH: IMalloc;
begin
if SUCCEEDED(SHGetSpecialFolderLocation(Application.Handle, AFolder, ItemIDList))
then
begin
try
hPath:= StrAlloc(max_path);
try
if SHGetPathFromIDList (ItemIDList, hPath)
then
Result:=hPath;
finally
StrDispose(hPath);
end;
finally
if SHGetMalloc(ShellH) = NOERROR
then
ShellH.Free(ItemIDList);
end;
end
else
RaiseLastOSError;
end;