1 | unit UApplicationInfo;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | SysUtils, Registry, Classes, Forms, URegistry;
|
---|
9 |
|
---|
10 | type
|
---|
11 |
|
---|
12 | { TApplicationInfo }
|
---|
13 |
|
---|
14 | TApplicationInfo = class(TComponent)
|
---|
15 | private
|
---|
16 | FIdentification: Byte;
|
---|
17 | FVersionMajor: Byte;
|
---|
18 | FVersionMinor: Byte;
|
---|
19 | FVersionBugFix: Byte;
|
---|
20 | FVersionSuffix: string; // alfa, beta, RC1, RC2, ...
|
---|
21 | FCompanyName: string;
|
---|
22 | FCompanyHomePage: string;
|
---|
23 | FHomePage: string;
|
---|
24 | FAuthorsName: string;
|
---|
25 | FEmailContact: string;
|
---|
26 | FAppName: string;
|
---|
27 | FReleaseDate: TDateTime;
|
---|
28 | FRegistryKey: string;
|
---|
29 | FRegistryRoot: TRegistryRoot;
|
---|
30 | function GetVersion: string;
|
---|
31 | public
|
---|
32 | constructor Create(AOwner: TComponent); override;
|
---|
33 | property Version: string read GetVersion;
|
---|
34 | published
|
---|
35 | property Identification: Byte read FIdentification write FIdentification;
|
---|
36 | property VersionMajor: Byte read FVersionMajor write FVersionMajor;
|
---|
37 | property VersionMinor: Byte read FVersionMinor write FVersionMinor;
|
---|
38 | property VersionBugFix: Byte read FVersionBugFix write FVersionBugFix;
|
---|
39 | property VersionSuffix: string read FVersionSuffix write FVersionSuffix;
|
---|
40 | property CompanyName: string read FCompanyName write FCompanyName;
|
---|
41 | property CompanyHomePage: string read FCompanyHomePage write FCompanyHomePage;
|
---|
42 | property HomePage: string read FHomePage write FHomePage;
|
---|
43 | property AuthorsName: string read FAuthorsName write FAuthorsName;
|
---|
44 | property EmailContact: string read FEmailContact write FEmailContact;
|
---|
45 | property AppName: string read FAppName write FAppName;
|
---|
46 | property ReleaseDate: TDateTime read FReleaseDate write FReleaseDate;
|
---|
47 | property RegistryKey: string read FRegistryKey write FRegistryKey;
|
---|
48 | property RegistryRoot: TRegistryRoot read FRegistryRoot write FRegistryRoot;
|
---|
49 | end;
|
---|
50 |
|
---|
51 | procedure Register;
|
---|
52 |
|
---|
53 | implementation
|
---|
54 |
|
---|
55 | procedure Register;
|
---|
56 | begin
|
---|
57 | RegisterComponents('Samples', [TApplicationInfo]);
|
---|
58 | end;
|
---|
59 |
|
---|
60 | { TApplicationInfo }
|
---|
61 |
|
---|
62 | function TApplicationInfo.GetVersion: string;
|
---|
63 | begin
|
---|
64 | Result := IntToStr(FVersionMajor) + '.' + IntToStr(FVersionMinor);
|
---|
65 | if FVersionSuffix <> '' then Result := Result + ' ' + FVersionSuffix
|
---|
66 | else Result := Result + '.' + IntToStr(FVersionBugFix);
|
---|
67 | end;
|
---|
68 |
|
---|
69 | constructor TApplicationInfo.Create(AOwner: TComponent);
|
---|
70 | begin
|
---|
71 | inherited Create(AOwner);
|
---|
72 | FVersionMajor := 1;
|
---|
73 | FIdentification := 1;
|
---|
74 | FAppName := Application.Name;
|
---|
75 | FRegistryKey := '\Software\' + FAppName;
|
---|
76 | FRegistryRoot := rrKeyCurrentUser;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | end.
|
---|