Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   "AppData" für Dienst (https://www.delphipraxis.net/175859-appdata-fuer-dienst.html)

ByTheTime 24. Jul 2013 12:52

"AppData" für Dienst
 
Moin,
eine Anwendung schreibt Daten in eine Konfigurations-Datei. Ein Dienst soll diese auslesen. Allerdings suche ich einen geeigneten Ort, wo diese Datei gespeichert werden soll. Mit dieser Funktion habe ich bisher immer den AppData-Pfad ermittelt.

Delphi-Quellcode:
function AppDataPath: string;
const
  SHGFP_TYPE_CURRENT = 0;
var
  path: array [0 .. MaxChar] of char;
begin
  SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, SHGFP_TYPE_CURRENT, @path[0]);
  Result := StrPas(path) + '\MeineApp\';
end;
Da ein Dienst allerdings unter "Lokales System" läuft, bringt mir diese Funktion natürlich kein sinnvolles Ergebnis. Welches Verzeichnis nutzen Dienste im Normalfall als Arbeitsverzeichnis

Danke,
Lukas

Union 24. Jul 2013 13:50

AW: "AppData" für Dienst
 
Vielleicht ein UNterverzeichnis von MSDN-Library durchsuchenCSIDL_COMMON_APPDATA

Klaus01 24. Jul 2013 13:51

AW: "AppData" für Dienst
 
Hallo,

ich verstehe nicht warum "CSIDL_LOCAL_APPDATA" wenn es in einer Service-Applikation verwendet wird
ein anderes Ergebnis liefern sollte als wenn es aus einer "normalen" Applikation verwendet wird?

Grüße
Klaus

Union 24. Jul 2013 13:59

AW: "AppData" für Dienst
 
Weil es unter einem Systembenutzer läuft.

Klaus01 24. Jul 2013 14:03

AW: "AppData" für Dienst
 
danke - vielleicht hätte ich vorher nachschauen sollen ;o)

Zitat:

The file system directory that serves as a common repository for
application-specific data.
A typical path is C:\Documents and Settings\username\Application Data.
Grüße
Klaus

ByTheTime 24. Jul 2013 15:08

AW: "AppData" für Dienst
 
Danke "CSIDL_LOCAL_APPDATA" gibt mir "C:\ProgramData" zurück, genau das habe ich gesucht :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz