Autor Beitrag
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 02.05.05 10:15 
Im Bezug zu diesem Thread, bin ich ein wenig ins Grübeln gekommen.
Ich würde gerne Dateien ins Anwender-Verzeichnis (INI-Dateien) ablegen.
Aber wie stelle ich in Delphi fest, wie dieses heißt?
Bevor jemand meckert: Die Suche habe ich versucht. Leider nichts passendes gefunden.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 02.05.05 10:27 
Hallo!

Der FAQ Beitrag ...wie kann ich spezielle Ordner finden? zusammen mit der Konstante CSIDL_APPDATA oder CSIDL_COMMON_APPDATA könnte das entsprechende Verzeichnis liefern. Bin mir aber nicht 100%ig sicher.

Gruß
Tino
Amiga-Fan
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 534



BeitragVerfasst: Mo 02.05.05 10:37 
hm also wenn hier über die Suche fast nix dazu zu finden ist und es nichtmal eine native Delphi-Funktion dafür gibt, kann man den Leuten auch kaum einen Vorwurf machen, wenn das nicht genutzt wird....

zuhause schaue ich nochmal nach... wenn mir keiner zuvorkommmt...
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 02.05.05 10:43 
@Tino: Die Konstanten müssten laut der Beschreibungen hinhauen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
jasocul Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 02.05.05 10:49 
Ich probiere es heute mal aus. Ergebnis teile ich dann mit.

Ergebnis:
Funktioniert einwandfrei.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
uses
  ActiveX, ShlObj;

Function GetUserAppDataPath : String;
var
  pIdL: PItemIDList;
  Path: Array [0..Max_Path] Of Char;
  Allocator: IMalloc;
Begin
  // ItemIdList für den Ordner holen
  SHGetSpecialFolderLocation (0, CSIDL_APPDATA, pIdL);

  // ItemIdList in String umwandeln lassen
  SHGetPathFromIDList (pIDL, Path);

  // Speicher wieder freigeben
  If Succeeded (SHGetMalloc (Allocator)) Then
    Begin
      Allocator.Free (pIdL);
      {$IFDEF VER100}
      Allocator.Release;
      {$ENDIF}
    End;

  Result := Path;
end;


@Tino: In meinem Source steht selbstverständlich ein Hinweis auf die Quelle. Du bist namentlich genannt, wie es sich gehört. :wink:
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 02.05.05 13:29 
user profile iconAmiga-Fan hat folgendes geschrieben:
und es nichtmal eine native Delphi-Funktion dafür gibt,

Was hat die Programmiersprache damit zu tun? Die API muss es hergeben und das tut sie, wie man sieht.
jasocul Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 02.05.05 13:34 
Und ich werde mal nachsehen, wie es unter .NET geht. Da gibt es keine API-Aufrufe. :wink:
Habs gefunden. Unter .NET heißt der Aufruf:
ausblenden Delphi-Quelltext
1:
environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);					
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 02.05.05 21:40 
Guck mal ins .NET Framework SDK unter Application rein. Stichworte:
  • CommonAppDataPath
  • CommonAppDataRegistry
  • UserAppDataPath
  • UserAppDataRegistry

Das Witzige ist, dass die Pfade auch gleich noch erstellt werden. Die Registrykeys habe ich nicht ausprobiert, aber ich schätze, da wird´s ähnlich sein ;). Die Namen richten sich nach Firma/Anwendungsname/Versionsnummer.
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Mo 02.05.05 23:44 
user profile iconTino hat folgendes geschrieben:
Der FAQ Beitrag ...wie kann ich spezielle Ordner finden? zusammen mit der Konstante CSIDL_APPDATA oder CSIDL_COMMON_APPDATA könnte das entsprechende Verzeichnis liefern. Bin mir aber nicht 100%ig sicher.


Ist richtig, aber mit einem "aber". Für alle die Delphi 6 usw. haben ist das richtig. Für alle die Delphi 3 haben, und das sind viele hier, fehlt die CSIDL_COMMON_APPDATA Konstante. In diesem Fall muß man den passenden Integerwert nehmen.

Hier habe ich ein kleines Programm mit dem es möglich ist alle Pfade auszulesen. Die ListBox1 sollte dabei das ganze Fenster füllen, da die Pfade lang sind:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
uses Shlobj;

function SpecialDirectory(ID: Integer): String;
var
  pidl : PItemIDList;
  Path : PChar;
begin  {Liefert den Pfad eines virtuellen Ordners //uses Shlobj;}
  if SUCCEEDED(SHGetSpecialFolderLocation(0, ID, pidl)) then
  begin
    Path := StrAlloc(max_path);
    SHGetPathFromIDList(pidl, Path);
    Result := String(Path);
  end
    else Result := '';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  for i := 0 to 128 do
  begin
    ListBox1.Items.Add(Format('Wert: %d - Pfad: %s', [i, SpecialDirectory(i)]));
  end;
end;

_________________
Popov
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 03.05.05 08:12 
user profile iconPopov hat folgendes geschrieben:
Für alle die Delphi 6 usw. haben ist das richtig. Für alle die Delphi 3 haben, und das sind viele hier, fehlt die CSIDL_COMMON_APPDATA Konstante. In diesem Fall muß man den passenden Integerwert nehmen.

Oder man nimmt sich die Werte und Konstantennnamen aus den Headerdateien von Microsofts PSDK. Das ist sowieso zu empfehlen, auch wenn man nur Hobby-Entwickler ist, zumal das PSDK ja auch nichts kostet.