/
About.cpp
92 lines (71 loc) · 2.21 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
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
/*
* About property page.
*/
#include "StdAfx.h"
#include "NetPerSec.h"
#include "About.h"
#pragma comment(lib, "version.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/* CAboutPage message handlers */
void InitDlg(HWND hDlg) {
// Get version information from the application
HINSTANCE hInst = AfxGetInstanceHandle();
TCHAR szFullPath[256];
GetModuleFileName(hInst, szFullPath, sizeof(szFullPath));
DWORD dwVerHnd;
DWORD dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
if (dwVerInfoSize != 0) {
// If we were able to get the information, process it
HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
LPVOID lpvMem = GlobalLock(hMem);
GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
TCHAR szGetName[256];
lstrcpy(szGetName, _T("\\StringFileInfo\\040904b0\\"));
int cchRoot = lstrlen(szGetName);
// Walk through the dialog items that we want to replace
static WORD idcs[] = {IDC_COPYRIGHT, IDC_VERSION};
for (int i = 0; i < 2; i++) {
TCHAR szResult[256];
::GetDlgItemText(hDlg, idcs[i], szResult, sizeof(szResult));
lstrcpy(&szGetName[cchRoot], szResult);
LPTSTR lszVer = NULL;
UINT cchVer = 0;
BOOL fRet = VerQueryValue(lpvMem, szGetName, (void**)&lszVer, &cchVer);
if (fRet && cchVer != 0 && lszVer != NULL) {
// Replace dialog item text with version info
lstrcpy(szResult, lszVer);
::SetDlgItemText(hDlg, idcs[i], szResult);
}
}
GlobalUnlock(hMem);
GlobalFree(hMem);
}
}
// CAboutPage property page
IMPLEMENT_DYNCREATE(CAboutPage, CPropertyPage)
CAboutPage::CAboutPage() : CPropertyPage(CAboutPage::IDD) {
//{{AFX_DATA_INIT(CAbout)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CAboutPage::~CAboutPage() {}
void CAboutPage::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutPage)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutPage, CPropertyPage)
//{{AFX_MSG_MAP(CAboutPage)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CAboutPage::OnInitDialog() {
CDialog::OnInitDialog();
InitDlg(GetSafeHwnd());
return TRUE;
}