unit Versioninfo;
interface
uses
Types,windows,SysUtils;
type
TVersionInfo=class
private
FStandardKeys:
array[0..9]
of String;
// Beinhaltet Alle FileInfos
function GetVersioninfo(
Index: Integer):
String;
function GetKey(KeyName:
String):
String;
procedure SetVersionInfo(
const Index: Integer;
const Value:
String);
function GetBuildNumber:
String;
public
constructor Create (ThisSourceFile:
String);
destructor Destroy;
override;
property Key[KeyName:
String]:
String read GetKey;
property CompanyName:
String index 0
read GetVersionInfo
write SetVersionInfo;
property FileDescription:
String index 1
read GetVersionInfo;
property FileVersion:
String index 2
read GetVersionInfo;
property InternalName:
String index 3
read GetVersionInfo;
property Copyright:
String index 4
read GetVersionInfo;
property TradeMarks:
String index 5
read GetVersionInfo;
property OriginalFileName:
String index 6
read GetVersionInfo;
property ProductName:
String index 7
read GetVersionInfo
write SetVersionInfo;
property ProductVersion:
String index 8
read GetVersionInfo
write SetVersionInfo;
property Comments:
String index 9
read GetVersionInfo;
property BuildNumber:
String read GetBuildNumber;
// Hier versuche ich auf die Eigenschaften zuzugreifen. Leider schlägt das Kompilieren fehl:
// [Error] Versioninfo.pas(35): Incompatible types
property StandardKeys[
index: Integer]:
String read GetVersionInfo
write SetVersionInfo;
end;
implementation
{ TVersionInfo }
const MaxVersionKeys= 9;
constructor TVersionInfo.Create(ThisSourceFile:
String);
const
VersionkeyNames:
array[0..MaxVersionKeys]
of String = ('
CompanyName',
'
FileDescription','
FileVersion','
InternalName','
Copyright','
TradeMarks',
'
OriginalFileName','
ProductName','
ProductVersion','
Comments');
var
ThisInfo: Integer;
InfoLength: UInt64;
Len,
Handle: DWord;
PCharset: PLongint;
LangCharset:
String;
InfoAvailable: Boolean;
begin
inherited Create;
// Get size of version info
Len:= GetFileVersionInfoSize(PChar(ThisSourceFile),
Handle);
// Allocate VersionInfo buffer size
SetLength(VersionInfo, Len+1);
//Get version info
if GetFileVersionInfo(PChar(ThisSourceFile),
Handle,Len,Pointer(VersionInfo))
then
begin
if VerQueryValue(Pointer(VersionInfo),'
\VarFileInfo\Translation',
Pointer(PCharSet),Len)
then
begin
LangCharset:= Format('
%.4x%.4x',[LoWord(PCharset^),HiWord(PCharset^)]);
InfoAvailable:= true;
for ThisInfo:=0
to MaxVersionKeys
do
begin
// Hier sollen die Informationen übernommen werden...
StandardKeys[ThisInfo]:= GetKey(VersionKeyNames[ThisInfo]);
end;
end;
end;
end;
destructor TVersionInfo.Destroy;
begin
inherited;
end;
function TVersionInfo.GetBuildNumber:
String;
begin
end;
function TVersionInfo.GetKey(KeyName:
String):
String;
var
begin
end;
function TVersionInfo.GetVersioninfo(
Index: Integer):
String;
begin
result:= FStandardKeys[
Index]
end;
procedure TVersionInfo.SetVersionInfo(
const Index: Integer;
const Value:
String);
begin
FStandardKeys[
Index]:= Value;
end;
end.