//uses ShlObj
function GetSpecialFolderDir(const folderid: integer): string;
var
pidl: pItemIDList;
buffer: array[0..255] of char;
begin
SHGetSpecialFolderLocation(application.Handle, folderid, pidl);
SHGetPathFromIDList(pidl, buffer);
Result := strpas(buffer);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
Memo1.Lines.Add(Format('%26s : %s', ['Template文件夹', GetSpecialFolderDir(21)]));
Memo1.Lines.Add(Format('%26s : %s', ['Template文件夹(All)', GetSpecialFolderDir(45)]));
end;