-
Notifications
You must be signed in to change notification settings - Fork 3
/
About.cpp
62 lines (52 loc) · 1.82 KB
/
About.cpp
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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "About.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TAboutDlg *AboutDlg;
static AnsiString GetProgramVersionString()
{
DWORD t;
DWORD size = GetFileVersionInfoSize("FwCalc.exe", &t);
AnsiString ret = "unknown";
if(size)
{
void *buf = malloc(size);
if(!buf) return ret;
if(GetFileVersionInfo("FwCalc.exe", NULL, size, buf))
{
LPVOID value;
UINT val_len;
if(VerQueryValue(buf, TEXT("\\StringFileInfo\\040904E4\\FileVersion"),&value, &val_len))
{
ret = (LPSTR)value;
}
}
free(buf);
}
return ret;
}
//---------------------------------------------------------------------------
__fastcall TAboutDlg::TAboutDlg(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TAboutDlg::FormCreate(TObject *Sender)
{
Version->Caption = AnsiString("Version: ") + GetProgramVersionString();
CompileTime->Caption = AnsiString("Compiled: ") + __DATE__ + " " + __TIME__;
}
//---------------------------------------------------------------------------
void __fastcall TAboutDlg::OkClick(TObject *Sender)
{
Hide();
}
//---------------------------------------------------------------------------
void __fastcall TAboutDlg::HomepageURLClick(TObject *Sender)
{
ShellExecute(NULL, "open", "http://fwcalc.sourceforge.net/", "", "", SW_SHOWDEFAULT);
}
//---------------------------------------------------------------------------