- Changed versions to be read from the resource stream
This commit is contained in:
parent
de33600726
commit
4b5cf332ca
|
@ -19,7 +19,7 @@
|
|||
<MinorVersionNr Value="6"/>
|
||||
<RevisionNr Value="1"/>
|
||||
<BuildNr Value="209"/>
|
||||
<StringTable CompanyName="AKS DataBasis" FileDescription="UO CentrED" InternalName="CentrED" LegalCopyright="Andreas Schneider" OriginalFilename="CentrED.exe" ProductName="CentrED" ProductVersion=""/>
|
||||
<StringTable CompanyName="AKS DataBasis" FileDescription="UO CentrED" InternalName="CentrED" LegalCopyright="Andreas Schneider" OriginalFilename="CentrED.exe" ProductName="CentrED" ProductVersion="0.6.1"/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="3">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
|
|
|
@ -12,11 +12,11 @@ object frmAbout: TfrmAbout
|
|||
Font.Height = -11
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
LCLVersion = '0.9.31'
|
||||
object Label3: TLabel
|
||||
Left = 8
|
||||
Height = 53
|
||||
Top = 189
|
||||
Top = 178
|
||||
Width = 338
|
||||
Align = alTop
|
||||
BorderSpacing.Top = 16
|
||||
|
@ -28,7 +28,7 @@ object frmAbout: TfrmAbout
|
|||
object Label5: TLabel
|
||||
Left = 8
|
||||
Height = 14
|
||||
Top = 98
|
||||
Top = 87
|
||||
Width = 338
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 8
|
||||
|
@ -39,7 +39,7 @@ object frmAbout: TfrmAbout
|
|||
object Label6: TLabel
|
||||
Left = 16
|
||||
Height = 53
|
||||
Top = 112
|
||||
Top = 101
|
||||
Width = 330
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 16
|
||||
|
@ -50,7 +50,7 @@ object frmAbout: TfrmAbout
|
|||
object Label7: TLabel
|
||||
Left = 8
|
||||
Height = 14
|
||||
Top = 84
|
||||
Top = 73
|
||||
Width = 338
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 8
|
||||
|
@ -61,32 +61,32 @@ object frmAbout: TfrmAbout
|
|||
end
|
||||
object Panel2: TPanel
|
||||
Left = 0
|
||||
Height = 76
|
||||
Height = 65
|
||||
Top = 0
|
||||
Width = 354
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Bottom = 8
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 76
|
||||
ClientHeight = 65
|
||||
ClientWidth = 354
|
||||
TabOrder = 0
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 76
|
||||
Height = 65
|
||||
Top = 0
|
||||
Width = 167
|
||||
Width = 190
|
||||
AutoSize = True
|
||||
BevelInner = bvRaised
|
||||
BevelOuter = bvLowered
|
||||
ClientHeight = 76
|
||||
ClientWidth = 167
|
||||
ClientHeight = 65
|
||||
ClientWidth = 190
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 2
|
||||
Height = 38
|
||||
Top = 2
|
||||
Width = 163
|
||||
Width = 186
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
AutoSize = False
|
||||
|
@ -99,9 +99,9 @@ object frmAbout: TfrmAbout
|
|||
end
|
||||
object lblVersion: TLabel
|
||||
Left = 6
|
||||
Height = 14
|
||||
Height = 1
|
||||
Top = 40
|
||||
Width = 155
|
||||
Width = 178
|
||||
Align = alTop
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Left = 4
|
||||
|
@ -111,11 +111,12 @@ object frmAbout: TfrmAbout
|
|||
object lblCopyright: TLabel
|
||||
Left = 6
|
||||
Height = 14
|
||||
Top = 58
|
||||
Width = 155
|
||||
Top = 45
|
||||
Width = 178
|
||||
Align = alTop
|
||||
Alignment = taCenter
|
||||
BorderSpacing.Around = 4
|
||||
Caption = 'Copyright 2011 Andreas Schneider'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
|
@ -123,7 +124,7 @@ object frmAbout: TfrmAbout
|
|||
object Panel3: TPanel
|
||||
Left = 8
|
||||
Height = 25
|
||||
Top = 250
|
||||
Top = 239
|
||||
Width = 338
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 8
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2007 Andreas Schneider
|
||||
* Portions Copyright 2011 Andreas Schneider
|
||||
*)
|
||||
unit UfrmAbout;
|
||||
|
||||
|
@ -62,7 +62,8 @@ var
|
|||
|
||||
implementation
|
||||
|
||||
{$I version.inc}
|
||||
uses
|
||||
vinfo;
|
||||
|
||||
{ TfrmAbout }
|
||||
|
||||
|
@ -73,8 +74,7 @@ end;
|
|||
|
||||
procedure TfrmAbout.FormCreate(Sender: TObject);
|
||||
begin
|
||||
lblVersion.Caption := Format('Version %s', [ProductVersion]);
|
||||
lblCopyright.Caption := Format('Copyright %s', [Copyright]);
|
||||
lblVersion.Caption := Format('Version %s', [VersionInfo.GetProductVersionString]);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<MinorVersionNr Value="6"/>
|
||||
<RevisionNr Value="1"/>
|
||||
<BuildNr Value="209"/>
|
||||
<StringTable CompanyName="AKS DataBasis" FileDescription="CentrED Server" InternalName="CentrED Server" LegalCopyright="Andreas Schneider" OriginalFilename="cedserver.exe" ProductName="CentrED"/>
|
||||
<StringTable CompanyName="AKS DataBasis" FileDescription="CentrED Server" InternalName="CentrED Server" LegalCopyright="Andreas Schneider" OriginalFilename="cedserver.exe" ProductName="CentrED" ProductVersion="0.6.1"/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="3">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
|
@ -219,7 +219,6 @@
|
|||
<IncludeFiles Value="..;../Imaging"/>
|
||||
<OtherUnitFiles Value="..;../UOLib;../MulProvider;../Imaging/ZLib"/>
|
||||
<UnitOutputDirectory Value="../obj"/>
|
||||
<SrcPath Value="..;../UOLib;../MulProvider;../Imaging/ZLib"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2008 Andreas Schneider
|
||||
* Portions Copyright 2011 Andreas Schneider
|
||||
*)
|
||||
program cedserver;
|
||||
|
||||
|
@ -31,18 +31,14 @@ uses
|
|||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
SysUtils, UConfig, UCEDServer;
|
||||
|
||||
{$I version.inc}
|
||||
|
||||
{$IFDEF WINDOWS}{$R cedserver.rc}{$ENDIF}
|
||||
SysUtils, UConfig, UCEDServer, vinfo;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Writeln('');
|
||||
Writeln('CentrED Server Version ', ProductVersion);
|
||||
Writeln('Copyright ', Copyright);
|
||||
Writeln('CentrED Server Version ', versionInfo.GetProductVersionString);
|
||||
Writeln('Copyright 2011 Andreas Schneider');
|
||||
//Writeln('================================');
|
||||
Writeln('');
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
unit vinfo;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, resource, versiontypes, versionresource;
|
||||
|
||||
type
|
||||
TVersionPrecision = 1..4;
|
||||
|
||||
{ TVersionInfo }
|
||||
|
||||
TVersionInfo = class
|
||||
private
|
||||
FVersResource: TVersionResource;
|
||||
function GetFixedInfo: TVersionFixedInfo;
|
||||
function GetStringFileInfo: TVersionStringFileInfo;
|
||||
function GetVarFileInfo: TVersionVarFileInfo;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure Load(Instance: THandle);
|
||||
property FixedInfo: TVersionFixedInfo read GetFixedInfo;
|
||||
property StringFileInfo: TVersionStringFileInfo read GetStringFileInfo;
|
||||
property VarFileInfo: TVersionVarFileInfo read GetVarFileInfo;
|
||||
|
||||
//Helper functions
|
||||
function GetProductVersionString(AMinPrecision: TVersionPrecision = 2): String;
|
||||
end;
|
||||
|
||||
var
|
||||
VersionInfo: TVersionInfo;
|
||||
|
||||
implementation
|
||||
|
||||
{ TVersionInfo }
|
||||
|
||||
function TVersionInfo.GetFixedInfo: TVersionFixedInfo;
|
||||
begin
|
||||
Result := FVersResource.FixedInfo;
|
||||
end;
|
||||
|
||||
function TVersionInfo.GetStringFileInfo: TVersionStringFileInfo;
|
||||
begin
|
||||
Result := FVersResource.StringFileInfo;
|
||||
end;
|
||||
|
||||
function TVersionInfo.GetVarFileInfo: TVersionVarFileInfo;
|
||||
begin
|
||||
Result := FVersResource.VarFileInfo;
|
||||
end;
|
||||
|
||||
constructor TVersionInfo.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
FVersResource := TVersionResource.Create;
|
||||
end;
|
||||
|
||||
destructor TVersionInfo.Destroy;
|
||||
begin
|
||||
FVersResource.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TVersionInfo.Load(Instance: THandle);
|
||||
var
|
||||
Stream: TResourceStream;
|
||||
begin
|
||||
Stream := TResourceStream.CreateFromID(Instance, 1, PChar(RT_VERSION));
|
||||
try
|
||||
FVersResource.SetCustomRawDataStream(Stream);
|
||||
// access some property to load from the stream
|
||||
FVersResource.FixedInfo;
|
||||
// clear the stream
|
||||
FVersResource.SetCustomRawDataStream(nil);
|
||||
finally
|
||||
Stream.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVersionInfo.GetProductVersionString(AMinPrecision: TVersionPrecision = 2): String;
|
||||
var
|
||||
productVersion: TFileProductVersion;
|
||||
lastVersion, i: Integer;
|
||||
begin
|
||||
productVersion := FixedInfo.ProductVersion;
|
||||
lastVersion := 3;
|
||||
while (lastVersion >= AMinPrecision) and (productVersion[lastVersion] = 0) do
|
||||
dec(lastVersion);
|
||||
|
||||
Result := '';
|
||||
for i := 0 to lastVersion do
|
||||
begin
|
||||
Result := Result + IntToStr(productVersion[i]);
|
||||
if i < lastVersion then
|
||||
Result := Result + '.';
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
VersionInfo := TVersionInfo.Create;
|
||||
VersionInfo.Load(HINSTANCE);
|
||||
|
||||
finalization
|
||||
VersionInfo.Free;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue