![]() |
AW: application.exename
Zitat:
Delphi-Quellcode:
interface
uses System.IOUtils; type TPathHelper = record helper for TPath private public function GetDesktopFolder: string; function GetStartMenuFolder: string; end; implementation uses Winapi.SHFolder, Winapi.ShlObj; function TPathHelper.GetDesktopFolder: string; var LStr: array[0 .. MAX_PATH] of Char; begin SetLastError(ERROR_SUCCESS); if SHGetFolderPath(0, CSIDL_DESKTOPDIRECTORY, 0, 0, @LStr) = S_OK then Result := LStr; end; function TPathHelper.GetStartMenuFolder: string; var LStr: array[0 .. MAX_PATH] of Char; begin SetLastError(ERROR_SUCCESS); if SHGetFolderPath(0, CSIDL_STARTMENU, 0, 0, @LStr) = S_OK then Result := LStr; end; |
AW: application.exename
Ok an Class-Helper habe ich ehrlich gesagt nicht gedacht, da ich öfter mal Schlechtes darüber gelesen habe.
:thumb: |
AW: application.exename
Klasse!
Nur eine Kleinigkeit , Result sollte initialisiert werden....... Zitat:
Zitat:
|
AW: application.exename
Ich habs jetzt so gemacht
Delphi-Quellcode:
var
PathHelper: TPath; |
AW: application.exename
Zitat:
Einfach die Unit einbinden und dann zb :
Delphi-Quellcode:
Der ClassHelper erweitert Tpath um die funktionen
myDektop := Tpath.GetDesktopFolder;
|
AW: application.exename
Ich hätte die Methoden allerdings GetWinDesktopFolder und GetWinStartMenuFolder genannt. Wenn dann noch welche für MacOS oder Linux dazu kommen, kann man sie auch entsprechend benennen und kommt nicht durcheinander.
|
AW: application.exename
Zitat:
Wenn ich den Desktop will ist es doch egal ob ich aktuell unter Win oder OSX bin. Ist doch z.B bei TPath.GetDownloadsPath genau so oder? |
AW: application.exename
Äh. Ja. War ein Denkfehler von mir. :roll:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:13 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