Точнее полный вариант выглядит так
Код:
procedure TForm1.FormCreate(Sender: TObject);
var
shellMalloc: IMalloc;
ppidl: PItemIdList;
DesktopPath: string;
begin
ppidl := nil;
try
if SHGetMalloc(shellMalloc) = NOERROR then
begin
SHGetSpecialFolderLocation(Form1.Handle, CSIDL_DESKTOP, ppidl);
SetLength(DesktopPath, MAX_PATH);
if not SHGetPathFromIDList(ppidl, PChar(DesktopPath)) then
raise exception.create('SHGetPathFromIDList failed : invalid pidl');
SetLength(DesktopPath, lStrLen(PChar(DesktopPath)));
end;
finally
if ppidl <> nil then
shellMalloc.free(ppidl);
end;
label11.Caption:=DesktopPath; //тут string'ом сидит путь до рабочего стола
end;