AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Allgemeine Pfadangabe unter Delphi

Ein Thema von Ykcim · begonnen am 29. Dez 2006 · letzter Beitrag vom 30. Dez 2006
 
jbg

Registriert seit: 12. Jun 2002
3.485 Beiträge
 
Delphi 10.1 Berlin Professional
 
#14

Re: Allgemeine Pfadangabe unter Delphi

  Alt 30. Dez 2006, 14:49
Zitat von Ykcim:
Pfad:=ExtractFilePath(ParamStr(0));
Template:=(Pfad+'Main.dot');
Viel Spaß bei Windows Vista bzw. Win2000/XP ohne Schreibrechte auf das Verzeichnis.

Folgender Code liefert dir das "C:\Dokumente und Einstellungen\BENUTZER\Anwendungsdaten\MYAPPNAME" Verzeichnis.
Delphi-Quellcode:
uses
  Windows, ShlObj;

function GetAppDataDir: string;
var
  Malloc: IMalloc;
  pidl: PItemIDList;
  Buffer: string;
begin
  Result := '';
  { Windows 95 compatible way, Win98 supports SHGetSpecialFolderPath() }
  SHGetMalloc(Malloc);
  if SHGetSpecialFolderLocation(Application.Handle, CSIDL_APPDATA, pidl) = S_OK then
  begin
    try
      SetLength(Buffer, MAX_PATH + 1);
      if SHGetPathFromIDList(pidl, PChar(Buffer)) then
        Result := ExcludeTrailingPathDelimiter(Copy(Buffer, 1, StrLen(PChar(Buffer))));
    finally
      Malloc.Free(pidl);
    end;
  end;
end;

function GetMyAppDataDir(const AppName: string): string;
begin
  Result := GetAppDataDir;
  if AppName <> 'then
    Result := Result + '\' + AppName;
  ForceDirectories(Result); // create directory structure
end;


...
begin
  Template := GetMyAppDataDir('MyAppName') + '\Main.dot';
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:18 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz