unit SettingsPaths;
interface
Function LocalUserFilesPath:
String;
Function LocalAppDataPath(AppName:
String):
String;
Function AppDataPath(AppName:
String):
String;
implementation
Uses sysutils,windows,ShlObj,
ActiveX;
Function GetSpecialFolderLocation(csidl: integer):
String;
Var
pMalloc: IMalloc;
pidl: PItemIDList;
path:
Array[0..MAX_PATH]
Of Char;
Begin
Result := '
?';
If SHGetMalloc(pMalloc) = S_OK
Then Begin
SHGetSpecialFolderLocation(0, csidl, pidl);
SHGetPathFromIDList(pidl, path);
Result := IncludeTrailingPathDelimiter(Path);
pMalloc.Free(pidl);
End;
End;
Function LocalUserFilesPath:
String;
Begin
Result := IncludeTrailingPathDelimiter(GetSpecialFolderLocation(CSIDL_PERSONAL));
End;
Function LocalAppDataPath(AppName:
String):
String;
Begin
Result := IncludeTrailingPathDelimiter(GetSpecialFolderLocation(CSIDL_LOCAL_APPDATA));
Result := IncludeTrailingPathDelimiter(Result + AppName);
ForceDirectories(Result)
End;
Function AppDataPath(AppName:
String):
String;
Begin
Result := IncludeTrailingPathDelimiter(GetSpecialFolderLocation(CSIDL_APPDATA));
Result := IncludeTrailingPathDelimiter(Result + AppName);
ForceDirectories(Result)
End;
end.