首先添加shlobj单元procedure getFolder(aLocation: integer;var path:string);//path为输出参数 var pIdl: PItemIDList; hPath: PChar;begin if SUCCEEDED(SHGetSpecialFolderLocation(0, aLocation, pidl)) then begin hPath := StrAlloc(max_path) ; SHGetPathFromIDList(pIdl, hPath) ; path:=strpas(hpath); StrDispose(hPath) ; end; end;//关键参数aLocation可以是CSIDL_PROGRAMS,CSIDL_PERSONAL,CSIDL_STARTUP,CSIDL_FONTS,CSIDL_FAVORITES//应用procedure TForm1.Button1Click(Sender: TObject);varpath1:string;begingetFolder( CSIDL_PROGRAMS,path1);showmessage(path1) ;end;