uses shlobj;
...
function CreateFolder(Foldername: string; aLocation: integer) : boolean;
var pIdl: PItemIDList;
hPath: PChar;
begin
Result := False;
if SUCCEEDED(SHGetSpecialFolderLocation(0, aLocation, pidl)) then
begin
hPath := StrAlloc(max_path) ;
SHGetPathFromIDList(pIdl, hPath) ;
SetLastError(0) ;
CreateDirectory(PChar(hPath + '\' + Foldername), nil) ;
if (GetLastError() = 0) or(GetLastError() = ERROR_ALREADY_EXISTS) then
Result := true;
StrDispose(hPath) ;
end;
end;
{ Usage: }
procedure TForm1.Button1Click(Sender: TObject) ;
begin
{constants like 'CSIDL_PROGRAMS'
are defined in the ShlObj unit}
CreateFolder('MyProgramgroup', CSIDL_PROGRAMS) ;
end;