Thema: Delphi Application Path

Einzelnen Beitrag anzeigen

Furtbichler
(Gast)

n/a Beiträge
 
#28

AW: Application Path

  Alt 8. Okt 2013, 08:23
Und davor (rausgeschnibbelt aus einer größeren Unit)

Delphi-Quellcode:
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.
So, und wer jetzt seine INI ins Programmverzeichnis schmeißt, wird geteert und gefeedert (mit Doppel-E!).
  Mit Zitat antworten Zitat