Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Allgemeine Pfadangabe unter Delphi (https://www.delphipraxis.net/83252-allgemeine-pfadangabe-unter-delphi.html)

Ykcim 30. Dez 2006 09:57

Re: Allgemeine Pfadangabe unter Delphi
 
Hallo Chris

vielen Dank für Deine Erklärungen. Das waren Infos, die jemand, der Delphi durch learning by doing und in Fornen lesen (das war mein erstes Post-vielen Dank für das willkommen heißen) lernt, nie herausgefunden hätte.

Aber was sagst Du denn zu der Lösung, die ich jetzt zum Schluß beschrritten habe. Ist nicht sicher?

Vielen Dank

Ykcim

3_of_8 30. Dez 2006 10:21

Re: Allgemeine Pfadangabe unter Delphi
 
Doch, die letzte dürfte eigentlich passen.

Jedenfalls von den Pfaden her. Nur bin ich mir nicht so ganz sicher, was das OLE-Zeug betrifft, damit hab ich mich noch nie beschäftigt.

Christian Seehase 30. Dez 2006 14:12

Re: Allgemeine Pfadangabe unter Delphi
 
Moin Ykcim,

Die Problematik mit relativen Pfaden und Arbeitsverzeichnis ist unabhängig von der verwendeten Programmiersprache.

jbg 30. Dez 2006 14:49

Re: Allgemeine Pfadangabe unter Delphi
 
Zitat:

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;

phXql 30. Dez 2006 15:16

Re: Allgemeine Pfadangabe unter Delphi
 
Zitat:

Zitat von jbg
Viel Spaß bei Windows Vista bzw. Win2000/XP ohne Schreibrechte auf das Verzeichnis.

Für was brauch ein normaler User Schreibrechte auf ein Template?


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:11 Uhr.
Seite 2 von 2     12   

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