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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/* Project sword
GNU Copyleft GPL © 1995. Almost No Rights Reserved.
SUBSYSTEM: sword.exe Application
FILE: swrdabtd.cpp
AUTHOR: The Sword Project Team
OVERVIEW
========
Source file for implementation of swordAboutDlg (TDialog).
*/
#include <owl\owlpch.h>
#pragma hdrstop
#if !defined(__FLAT__)
#include <ver.h>
#endif
#include "swordapp.h"
#include "swrdabtd.h"
ProjectRCVersion::ProjectRCVersion (TModule *module)
{
char appFName[255];
char subBlockName[255];
DWORD fvHandle;
UINT vSize;
FVData = 0;
module->GetModuleFileName(appFName, sizeof(appFName));
OemToAnsi(appFName, appFName);
DWORD dwSize = ::GetFileVersionInfoSize(appFName, &fvHandle);
if (dwSize) {
FVData = (void FAR *)new char[(UINT)dwSize];
if (::GetFileVersionInfo(appFName, fvHandle, dwSize, FVData)) {
// Copy string to buffer so if the -dc compiler switch (Put constant strings in code segments)
// is on VerQueryValue will work under Win16. This works around a problem in Microsoft's ver.dll
// which writes to the string pointed to by subBlockName.
strcpy(subBlockName, "\\VarFileInfo\\Translation");
if (!::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&TransBlock, &vSize)) {
delete[] FVData;
FVData = 0;
} else
// Swap the words so wsprintf will print the lang-charset in the correct format.
*(DWORD *)TransBlock = MAKELONG(HIWORD(*(DWORD *)TransBlock), LOWORD(*(DWORD *)TransBlock));
}
}
}
ProjectRCVersion::~ProjectRCVersion ()
{
if (FVData)
delete[] FVData;
}
bool ProjectRCVersion::GetProductName (LPSTR &prodName)
{
UINT vSize;
char subBlockName[255];
if (FVData) {
wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"ProductName");
return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&prodName, &vSize) : false;
} else
return false;
}
bool ProjectRCVersion::GetProductVersion (LPSTR &prodVersion)
{
UINT vSize;
char subBlockName[255];
if (FVData) {
wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"ProductVersion");
return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&prodVersion, &vSize) : false;
} else
return false;
}
bool ProjectRCVersion::GetCopyright (LPSTR ©right)
{
UINT vSize;
char subBlockName[255];
if (FVData) {
wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"LegalCopyright");
return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)©right, &vSize) : false;
} else
return false;
}
bool ProjectRCVersion::GetDebug (LPSTR &debug)
{
UINT vSize;
char subBlockName[255];
if (FVData) {
wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"SpecialBuild");
return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&debug, &vSize) : false;
} else
return false;
}
//{{swordAboutDlg Implementation}}
//////////////////////////////////////////////////////////
// swordAboutDlg
// ==========
// Construction/Destruction handling.
swordAboutDlg::swordAboutDlg (TWindow *parent, TResId resId, TModule *module)
: TDialog(parent, resId, module)
{
// INSERT>> Your constructor code here.
}
swordAboutDlg::~swordAboutDlg ()
{
Destroy();
// INSERT>> Your destructor code here.
}
void swordAboutDlg::SetupWindow ()
{
LPSTR prodName = 0, prodVersion = 0, copyright = 0, debug = 0;
// Get the static text for the value based on VERSIONINFO.
TStatic *versionCtrl = new TStatic(this, IDC_VERSION, 255);
TStatic *copyrightCtrl = new TStatic(this, IDC_COPYRIGHT, 255);
TStatic *debugCtrl = new TStatic(this, IDC_DEBUG, 255);
TDialog::SetupWindow();
// Process the VERSIONINFO.
ProjectRCVersion applVersion(GetModule());
// Get the product name and product version strings.
if (applVersion.GetProductName(prodName) && applVersion.GetProductVersion(prodVersion)) {
// IDC_VERSION is the product name and version number, the initial value of IDC_VERSION is
// the word Version (in whatever language) product name VERSION product version.
char buffer[255];
char versionName[128];
buffer[0] = '\0';
versionName[0] = '\0';
versionCtrl->GetText(versionName, sizeof(versionName));
wsprintf(buffer, "%s %s %s", prodName, versionName, prodVersion);
versionCtrl->SetText(buffer);
}
//Get the legal copyright string.
if (applVersion.GetCopyright(copyright))
copyrightCtrl->SetText(copyright);
// Only get the SpecialBuild text if the VERSIONINFO resource is there.
if (applVersion.GetDebug(debug))
debugCtrl->SetText(debug);
}
|