-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathformabout.pas
80 lines (66 loc) · 1.62 KB
/
formabout.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
unit FormAbout;
{$mode objfpc}{$H+}
interface
uses
Classes, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls;
type
{ TfrmAbout }
TfrmAbout = class(TForm)
lbAuthor: TLabel;
lbTranslateAuthor: TLabel;
lbNameAndVer: TLabel;
lbAboutText: TLabel;
lbRepURL: TLabeledEdit;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
frmAbout: TfrmAbout;
implementation
uses
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF}
SysUtils;
{$R *.lfm}
{ TfrmAbout }
function GetMyVersion(VerCount: Byte = 4):string;
type
TVerInfo=packed record
Nevazhno: array[0..47] of byte; // ненужные нам 48 байт
Minor,Major,Build,Release: word; // а тут версия
end;
var
s:TResourceStream;
v:TVerInfo;
begin
result := '';
try
s:=TResourceStream.Create(HInstance,'#1',RT_VERSION); // достаём ресурс
if s.Size>0 then begin
s.Read(v,SizeOf(v)); // читаем нужные нам байты
// версия:
if VerCount >= 1 then
Result := Result + IntToStr(v.Major);
if VerCount >= 2 then
Result := Result + '.' + IntToStr(v.Minor);
if VerCount >= 3 then
Result := Result + '.' + IntToStr(v.Release);
if VerCount >= 4 then
Result := Result + '.' + IntToStr(v.Build);
end;
s.Free;
except;
end;
end;
procedure TfrmAbout.FormCreate(Sender: TObject);
begin
lbNameAndVer.Caption:='OpenModbusTool';
lbNameAndVer.Caption:=lbNameAndVer.Caption + ' ver.'+GetMyVersion(4);
lbAuthor.Caption:='Author: heXor';
end;
end.