Autor Beitrag
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 30.11.06 12:27 
hab folgendes:
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:
function GetSpecialFolder(iGUID: integer): string;
var
  shellMalloc : IMalloc;
  ppidl       : PItemIdList;
begin
  ppidl := nil;
  try
    if SHGetMalloc(shellMalloc) = NOERROR then
    begin
      SHGetSpecialFolderLocation(Form1.Handle, iGUID, ppidl);
      SetLength(Result, MAX_PATH);
      if not SHGetPathFromIDList(ppidl, PChar(Result)) then
        raise exception.create('SHGetPathFromIDList failed : invalid pidl');
      SetLength(Result, lStrLen(PChar(Result)));
    end;
  finally
   if ppidl <> nil then
         shellMalloc.free(ppidl);
  end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:=(GetSpecialFolder(CSIDL_DESKTOP));
end;


Dort komme ich aber eine Ebene zu weit, möchte gern nur im Verzeichnis des Users stehen.
Also statt:
"C:\Dokumente und Einstellungen\USER\Dektop"

will ich nur hier hin:
"C:\Dokumente und Einstellungen\USER"

Moderiert von user profile iconChristian S.: Quote- durch Delphi-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am Do 30.11.2006 um 11:31
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 30.11.06 12:35 
Nimm mal diesen Wert: CSIDL_PERSONAL
del1312 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 30.11.06 12:44 
nee das hatte ich schon, aber da lande ich im Ordner "Eigene Dateien" soweit will ich ja nicht, danke aber :o)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 30.11.06 12:56 
Aus der Doku:
Zitat:
CSIDL_PROFILE (0x0028)
    Version 5.0. The user's profile folder. A typical path is C:\Documents and Settings\username. Applications should not create files or folders at this level; they should put their data under the locations referred to by CSIDL_APPDATA or CSIDL_LOCAL_APPDATA.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 30.11.06 13:04 
user profile iconecspooky hat folgendes geschrieben:
Dort komme ich aber eine Ebene zu weit


Und wie kommt man eine Ebene zurück ? :shock: Gehe mal in "ausführen" und gebe ein :

ausblenden Quelltext
1:
%homepath%					


Ihr müßt mal etwas Kreativität mitbringen. :mrgreen: Und dann gebe mal folgendes ein :

ausblenden Quelltext
1:
%homepath%\..					


Habe mir den Code ehrlich gesagt nicht genau angesehen, aber die Richtung müßte stimmen.

_________________
Gruß
Hansa
del1312 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 30.11.06 13:18 
danke das wars: ..._PROFILE
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 30.11.06 13:20 
@Hansa: Man kann den Speicherort für "Eigene Dateien" beliebig festlegen. Meine "Eigenen Dateien" liegen in "D:\Eigene Dateien" und nicht "C:\Dokumente ...". Mit Deiner Methode würde man dann den völlig falschen Ordner bekommen. Ich wäre mir auch nicht sicher, ob die Ordnerstruktur in Vista genauso ist wie in XP. Daher ist der Weg über die entsprechenden Windows-Funktionen IMHO sicherer.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 30.11.06 13:28 
Der Ordner ist schlichtweg uninteressant. Es geht um "eine Ebene zurück" und das wird auch unter Vista "Ordner\.." sein. 8)

_________________
Gruß
Hansa
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 30.11.06 13:34 
user profile iconhansa hat folgendes geschrieben:
Der Ordner ist schlichtweg uninteressant.
Du hast völlig recht. Wenn ich einen bestimmten Ordner ermitteln will, ist der Ordner völlig uninteressant :roll:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 30.11.06 13:40 
user profile iconChristian S. hat folgendes geschrieben:
Wenn ich einen bestimmten Ordner ermitteln will, ist der Ordner völlig uninteressant :roll:


Christian, das da ist eines Physikers unwürdig. :mrgreen: Die Vorgehensweise ist lediglich : 1. man suche einen gegebenen Ordner. Wie ist egal. Der muß eben gefunden sein. 2. man gehe eine Verzeichnisstruktur-Ebene zurück.

_________________
Gruß
Hansa
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 30.11.06 13:43 
user profile iconhansa hat folgendes geschrieben:
Christian, das da ist eines Physikers unwürdig. :mrgreen:
Und Dein Vorgehen eines Programmierers 8)

user profile iconhansa hat folgendes geschrieben:
Die Vorgehensweise ist lediglich : 1. man suche einen gegebenen Ordner. Wie ist egal. Der muß eben gefunden sein. 2. man gehe eine Verzeichnisstruktur-Ebene zurück.
Und genau dieses Vorgehen ist bei obigem Problem nach hardcoden der Strings das wohl unbrauchbarste Vorgehen!

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Do 30.11.06 13:52 
Muß ich mich jetzt noch auf Diskussionen einlassen ? :D
user profile iconChristian S. hat folgendes geschrieben:
Und Dein Vorgehen eines Programmierers 8)


Siehe mein Beispiel %homepath%. Was ist da jetzt hardcoded ? Das \.. ? :shock: Ist das Ganze mit %XXX% nicht vom Betriebssystem zu erhalten, dann müßte man es aber tatsächlich wohl hardcoden oder eben eine eigene Umgebebungsvariable einführen.

_________________
Gruß
Hansa
del1312 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Do 30.11.06 14:09 
hey leute kein streit, ich danke euch für die tipps, hab das mit dem ..._PROFILE genommen und finde den weg auch am besten :D