![]() |
Delphi-Version: 10 Seattle
TPath.GetDownloadsPath
Hallo,
jetzt gibt es ja seit einigen Delphi Version in IOUtils TPath. Über diese Klasse kann ich mir verschiedene Pfade sehr komfortabel ermitteln. Jetzt bräuchte ich gerade das default Download-Verzeichnis des Benutzers und habe spontan mal
Code:
ausprobiert. Erwartet hätte ich:
TPath.GetDownloadsPath
Code:
erhalten habe ich aber:
C:\Benutzer\<Benutzername>\Downloads
Code:
So steht es ja auch in der Doku. Also die Funktion liefert das "richtige" Ergebnis.
C:\Benutzer\<Benutzername>\AppData\Local
Verstehe ich da was falsch? Oder ist das "C:\Benutzer\<Benutzername>\AppData\Local" per Definition für Downloads gedacht? Mir geht es in meinem Fall nur um Windows. |
AW: TPath.GetDownloadsPath
Das ist eine "Unschönheit" in Delphi.
Bin mir nicht ganz sicher aber als die IoUtils eingeführt wurden war glaube ich XP noch auf der Liste der unterstützten OS. Erst ab Vista gibt es die function SHGetKnownFolderPath mit der man auch das Downloadverzeichnis abfragen kann. Deshalb wurde in den IoUtils SHGetFolderPath benutzt. Die arbeitet mit CSIDL_xxxxx Konstanten und es gibt keine für den Downloadordner. Müsste von Embarcadero wohl mal überarbeitet werden. Jetzt hilft wohl nur die SHGetKnownFolderPath selbst zu kapseln, oder frech das %Userprofile%\Downloads zu benutzen |
AW: TPath.GetDownloadsPath
Siehe
![]() Suche in der Registry [HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Shell Folders] nach {374DE290-123F-4565-9164-39C4925E467B}. ![]() Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Shell Folders] "!Do not use this registry key"="Use the SHGetFolderPath or SHGetKnownFolderPath function instead" "AppData"="C:\\Users\\TheUser\\AppData\\Roamin g" "Local AppData"="C:\\Users\\TheUser\\AppData\\Local" "My Video"="C:\\Users\\TheUser\\Videos" "{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}"="C:\\Users\\TheUser\\AppData\\Roami ng\\Microsoft\\Windows\\Libraries" "My Pictures"="C:\\Users\\TheUser\\Pictures" "Desktop"="C:\\Users\\TheUser\\Desktop" "History"="C:\\Users\\TheUser\\AppData\\Local\\Mic rosoft\\Windows\\History" "NetHood"="C:\\Users\\TheUser\\AppData\\Roaming\\M icrosoft\\Windows\\Network Shortcuts" "{56784854-C6CB-462B-8169-88E350ACB882}"="C:\\Users\\TheUser\\Contacts" "{00BCFC5A-ED94-4E48-96A1-3F6217F21990}"="C:\\Users\\TheUser\\AppData\\Local \\Microsoft\\Windows\\RoamingTiles" "Cookies"="C:\\Users\\TheUser\\AppData\\Local\\Mic rosoft\\Windows\\INetCookies" "Favorites"="C:\\Users\\TheUser\\Favorites" "SendTo"="C:\\Users\\TheUser\\AppData\\Roaming\\Mi crosoft\\Windows\\SendTo" "Start Menu"="C:\\Users\\TheUser\\AppData\\Roaming\\Micro soft\\Windows\\Start Menu" "My Music"="C:\\Users\\TheUser\\Music" "Programs"="C:\\Users\\TheUser\\AppData\\Roaming\\ Microsoft\\Windows\\Start Menu\\Programs" "Recent"="C:\\Users\\TheUser\\AppData\\Roaming\\Mi crosoft\\Windows\\Recent" "CD Burning"="C:\\Users\\TheUser\\AppData\\Local\\Micr osoft\\Windows\\Burn\\Burn" "PrintHood"="C:\\Users\\TheUser\\AppData\\Roaming\ \Microsoft\\Windows\\Printer Shortcuts" "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}"="C:\\Users\\TheUser\\Searches" "{374DE290-123F-4565-9164-39C4925E467B}"="C:\\Users\\TheUser\\Downloads" "{A520A1A4-1780-4FF6-BD18-167343C5AF16}"="C:\\Users\\TheUser\\AppData\\Local Low" "Startup"="C:\\Users\\TheUser\\AppData\\Roaming\\M icrosoft\\Windows\\Start Menu\\Programs\\Startup" "Administrative Tools"="C:\\Users\\TheUser\\AppData\\Roaming\\Micr osoft\\Windows\\Start Menu\\Programs\\Administrative Tools" "Personal"="C:\\Users\\TheUser\\Documents" "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}"="C:\\Users\\TheUser\\Links" "Cache"="C:\\Users\\TheUser\\AppData\\Local\\Micro soft\\Windows\\INetCache" "Templates"="C:\\Users\\TheUser\\AppData\\Roaming\ \Microsoft\\Windows\\Templates" "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}"="C:\\Users\\TheUser\\Saved Games" "Fonts"="C:\\Windows\\Fonts" |
AW: TPath.GetDownloadsPath
Zitat:
|
AW: TPath.GetDownloadsPath
Zitat:
Kann man in XE7.System.IOUtils.pas sehen, dass der P. nicht ganz nüchtern war:
Delphi-Quellcode:
Das Einfachste ist doch folgende Zeile:
class function TPath.GetDownloadsPath: string;
{$IFDEF MSWINDOWS} var LStr: array[0 .. MAX_PATH] of Char; begin SetLastError(ERROR_SUCCESS); if SHGetFolderPath(0,CSIDL_LOCAL_APPDATA, 0, 0, @LStr) = S_OK then Result := LStr; end;
Delphi-Quellcode:
Caption:= GetEnvironmentVariable('USERPROFILE')+'\Downloads';
Aufruf des Explorers mit Downloads-Verzeichnis:
Delphi-Quellcode:
procedure TForm1.ButtonClick(Sender: TObject); // uses ShellApi
var FN: String; begin FN:= 'shell:::{374DE290-123F-4565-9164-39C4925E467B} '; ShellExecute(0,nil,PChar('explorer.exe'),PChar(FN),'',SW_SHOWNORMAL); end; |
AW: TPath.GetDownloadsPath
Ich verweise mal auf die
![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:42 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 by Thomas Breitkreuz