![]() |
FileInfo (Dateiversion und andere Resourcen)
Liste der Anhänge anzeigen (Anzahl: 1)
Diese "Klasse" ließt Dateiversion, das Kompilierungsdatum und die Versionsresource aus.
Delphi-Quellcode:
Beispiel:
// vsLong 1.2.3.4
// vsCompact 1.2-34 // vsShort 1.2 // vsNatural 1.2c if patch=0 then 1.2 | if patch>26 then 1.2.3 // vsNaturalBuild 1.2c (4) // Prefix v TVersionStr = (vsLong, vsCompact, vsShort, vsNatural, vsNaturalBuild, vsLongPrefix, vsCompactPrefix, vsShortPrefix, vsNaturalPrefix, vsNaturalBuildPrefix); TVersion = Record Private Function Get(Mode: TVersionStr): String; Public Property asString[Mode: TVersionStr]: String Read Get; Default; Case Integer of 0: (VersionMS, VersionLS: LongWord); 1: (Minor, Major: Word; Build, Patch: Word); 2: (MinorRelease, MajorRelease: Word; BuildNumber, PatchLevel: Word); End; TFileFlags = Set of (ffDebug, ffPrerelease, ffPatched, ffPrivateBuild, ffInfoInferred, ffSpecialBuild); {$MINENUMSIZE 2} TInfoKeyType = (ktBinary, ktText); {$MINENUMSIZE 1} TInfoLanguage = Record Private Function Get(Format: Integer): Word; Public Value: LongWord; Property LangID: Word Index $10FFFF Read Get; Property MajorLang: Word Index $1003FF Read Get; Property SubLang: Word Index $1AFC00 Read Get; Property Codepage: Word Index $00FFFF Read Get; End; TStringTable = Record Key: String; Typ: TInfoKeyType; Text: String; End; TStringFileInfo = Record Lang: TInfoLanguage; Table: Array of TStringTable; End; TFileInfo = Record Private FLang: LangID; ... Public FileVersion: TVersion; ProductVersion: TVersion; FileFlags: TFileFlags; FileOS: LongWord; // Windows.VOS_… FileType: LongWord; // Windows.VFT_… FileSubtype: LongWord; // Windows.VFT2_… FileDate: TDateTime; Strings: Array of TStringFileInfo; Class Function Get (Filename: String = ''): TFileInfo; Static; Function Load(Filename: String = ''): Boolean; Property Version[Mode: TVersionStr]: String Read GetVersion; // FileVersion + FileFlags Property Typ: String Read GetType; Function LanguagesCount: Integer; Property Languages[i: Integer]: LANGID Read GetLang; Property Language: LANGID Read FLang Write FLang; Property CompanyName: String Index 0 Read GetStr; Property ProductName: String Index 1 Read GetStr; Property ProductVersion_Str: String Index 2 Read GetStr; Property FileVersion_Str: String Index 3 Read GetStr; Property FileDescription: String Index 4 Read GetStr; Property InternalName: String Index 5 Read GetStr; Property OriginalFilename: String Index 6 Read GetStr; Property LegalCopyright: String Index 7 Read GetStr; Property LegalTrademarks: String Index 8 Read GetStr; Property Comments: String Index 9 Read GetStr; Property PrivateBuild: String Index 10 Read GetStr; Property SpecialBuild: String Index 11 Read GetStr; End;
Delphi-Quellcode:
wobei auch sowas möglich ist
var Info: TFileInfo;
Info.Load; // ohne Dateiname wird die eigene Anwendung ausgelesen ShowMessage(Info.Version[vsLong] + ' ' + DateTimeToStr(Info.FileDate)); // Freigeben nicht nötig (außer wenn man den Record zur Klasse umgebaut hat)
Delphi-Quellcode:
Noar, das Ganze ist zwar nicht als Klasse erstellt, aber es läßt sich notfalls umrüsten, indem man
x := TFileInfo.Get.FileDate;
Delphi-Quellcode:
durch dieses ersetzt
Class Function Get (Filename: String = ''): TFileInfo; Static;
Function Load(Filename: String = ''): Boolean;
Delphi-Quellcode:
Constructor Create(Filename: String = '');
@Manager der CL: Wir haben hierzu schon zwei sehr ähnliche Eintäge, in verschiedenen Rubriken. :shock: Code-Library -> Sonstiges -> ![]() Code-Library -> Dateien / Laufwerke -> ![]() |
Re: FileInfo (Dateiversion und andere Resourcen)
kleine Fehlerkorrektur
in TVersion wurden ein paar Words umgedreht (blödes LittleEndian, aber jetzt weiß ich endlich warum mir da was komisch vorkam) nja und ansonsten wurden auch ein paar andere Dinge anders gelöst. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:08 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