forked from keizi666/charu3
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAboutDialog.cpp
56 lines (48 loc) · 1.87 KB
/
AboutDialog.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
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "AboutDialog.h"
#include "resource.h"
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CString strInfo(_T(""));
TCHAR fileName[MAX_PATH + 1];
if (::GetModuleFileName(NULL, fileName, MAX_PATH + 1)) {
DWORD bufSize = ::GetFileVersionInfoSize(fileName, NULL);
BYTE* pVersion = new BYTE[bufSize];
if (pVersion) {
if (::GetFileVersionInfo(fileName, NULL, bufSize, pVersion)) {
UINT queryLen;
WORD* pLangCode = nullptr;
CString subBlock;
VS_FIXEDFILEINFO* pFileInfo = nullptr;
::VerQueryValue(pVersion, _T("\\"), (void**)&pFileInfo, &queryLen);
::VerQueryValue(pVersion, _T("\\VarFileInfo\\Translation"), (void**)&pLangCode, &queryLen);
TCHAR* pStrName = nullptr;
subBlock.Format(_T("\\StringFileInfo\\%04X%04X\\ProductName"), pLangCode[0], pLangCode[1]);
::VerQueryValue(pVersion, (LPTSTR)(LPCTSTR)subBlock, (void**)&pStrName, &queryLen);
if (queryLen > 0) {
strInfo += pStrName;
}
TCHAR* pStrVersion = nullptr;
subBlock.Format(_T("\\StringFileInfo\\%04X%04X\\ProductVersion"), pLangCode[0], pLangCode[1]);
::VerQueryValue(pVersion, (LPTSTR)(LPCTSTR)subBlock, (void**)&pStrVersion, &queryLen);
if (queryLen > 0) {
strInfo += " Version ";
strInfo += pStrVersion;
}
}
delete[] pVersion;
}
}
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_VERSION_NAME, strInfo);
}