Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi API-Befehl für Profilpfad? (https://www.delphipraxis.net/49455-api-befehl-fuer-profilpfad.html)

Esolit 11. Jul 2005 18:00


API-Befehl für Profilpfad?
 
Hi,

ich suche jetzt schon eine ganze Weile, kann aber keine API-Funktion finden die den Profilpfad zurückgibt. Mit Profilpfad meine ich z.B. C:\Dokumente und Einstellungen\UserName\. So etwas muss es doch aber geben :gruebel:

Grüße,

Esolit

Pr0g 11. Jul 2005 18:09

Re: API-Befehl für Profilpfad?
 
Das kannst du per CSIDL_PROFILE rausfinden, einfach Unit ShlObj einbinden und dann bspw. ne Funktion machen:
Delphi-Quellcode:
function GetProfileDir: String;
begin
  SetLength(Result, MAX_PATH);
  SHGetSpecialFolderPath(Application.Handle, PChar(Result), $0028, False); // $0028 -> CSIDL_PROFILE
  Result := PChar(Result);
end;
Mit anderen Ids gehts, aber CSIDL_PROFILE hat er irgendwie nicht, daher habe ich direkt den Wert $0028 genommen, weitere Infos in der MSDN: Link.

MfG Pr0g

ringli 11. Jul 2005 18:13

Re: API-Befehl für Profilpfad?
 
Wenn es nicht unbedingt API sein muss reicht dir das hier vielleicht:
Delphi-Quellcode:
GetEnvironmentVariable('userprofile')

NicoDE 11. Jul 2005 18:17

Re: API-Befehl für Profilpfad?
 
Zitat:

Zitat von ringli
Wenn es nicht unbedingt API sein muss

Die Variable ist nicht unbedingt gesetzt. Für den Zweck nimmt man normalerweise CSIDL_APPDATA (für ganz alte Windows Versionen ohne IE4 kann man die ShFolder.dll mitliefern).

marabu 11. Jul 2005 18:35

Re: API-Befehl für Profilpfad?
 
Und wenn man es richtig aufwendig machen will, dann mit der Funktion GetUserProfileDirectory() aus der USERENV.DLL - aber mir reicht auch die Umgebungsvariable.

Grüße vom marabu

Pr0g 11. Jul 2005 18:57

Re: API-Befehl für Profilpfad?
 
In den meisten Fällen braucht man sowieso das Anwendungsverzeichnis, da man nur dort und nicht direkt im Userverzeichnis seine Daten speichern soll.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:26 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