Einzelnen Beitrag anzeigen

Andreas L.

Registriert seit: 23. Mai 2011
Ort: Furth im Wald
308 Beiträge
 
Delphi 11 Alexandria
 
#8

AW: Wo müssen Applikationsdaten unter Win 7 gespeichert werden?

  Alt 29. Mär 2012, 18:04
Du kannst die Funktion von Luckie verwenden:
http://michael-puff.de/Programmierun.../HOMEDIR.shtml
Delphi-Quellcode:
function GetShellFolder(CSIDL: integer): string;
var
  pidl : PItemIdList;
  FolderPath : string;
  SystemFolder : Integer;
  Malloc : IMalloc;
begin
  Malloc := nil;
  FolderPath := '';
  SHGetMalloc(Malloc);
  if Malloc = nil then
  begin
    Result := FolderPath;
    Exit;
  end;
  try
    SystemFolder := CSIDL;
    if SUCCEEDED(SHGetSpecialFolderLocation(0, SystemFolder, pidl)) then
    begin
      SetLength(FolderPath, max_path);
      if SHGetPathFromIDList(pidl, PChar(FolderPath)) then
      begin
        SetLength(FolderPath, length(PChar(FolderPath)));
      end;
    end;
    Result := FolderPath;
  finally
    Malloc.Free(pidl);
  end;
end;
Bsp.:
Delphi-Quellcode:
uses
  ..., Windows, ShlObj, ActiveX;

...

var
  path: String;
begin
  path := GetShellFolder(CSIDL_APPDATA);
  path := IncludeTrailingPathDelimiter(path);
  ShowMessage(path);
end;
Liste aller CSIDL-Konstanten:
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Andreas Lauß
Blog
  Mit Zitat antworten Zitat