|
// About.cpp : implementation file
//
#include "stdafx.h"
#include "CreateInstaller.h"
#include "About.h"
#include ".\about.h"
struct VS_VERSIONINFO
{
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[1];
WORD wPadding1[1];
VS_FIXEDFILEINFO Value;
WORD wPadding2[1];
WORD wChildren[1];
};
// CAbout dialog
IMPLEMENT_DYNAMIC(CAbout, CDialog)
CAbout::CAbout(CWnd* pParent /*=NULL*/)
: CDialog(CAbout::IDD, pParent)
{
}
CAbout::~CAbout()
{
}
void CAbout::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, m_edtVer);
}
BEGIN_MESSAGE_MAP(CAbout, CDialog)
END_MESSAGE_MAP()
// CAbout message handlers
BOOL CAbout::OnInitDialog()
{
CDialog::OnInitDialog();
CString verStr;
LPCTSTR lpszFilename = _T("EasyInstaller.exe");
DWORD dwHandle, dwSize;
// determine the size of the resource information
dwSize = GetFileVersionInfoSize((LPTSTR)lpszFilename, &dwHandle);
if (0 < dwSize)
{
LPBYTE lpBuffer = new BYTE[dwSize];
#define roundoffs(a,b,r) (((BYTE *) (b) - (BYTE *) (a) + ((r) - 1)) & ~((r) - 1))
#define roundpos(a,b,r) (((BYTE *) (a)) + roundoffs(a,b,r))
GetFileVersionInfo((LPTSTR)lpszFilename, 0, dwSize, lpBuffer);
VS_VERSIONINFO *pVerInfo = (VS_VERSIONINFO *) lpBuffer;
// the fixed section starts right after the 'VS_VERSION_INFO' string
// LPBYTE pOffsetBytes = (BYTE *) &pVerInfo->szKey[_tcslen(pVerInfo->szKey) + 1];
LPBYTE pOffsetBytes = (BYTE *) &pVerInfo->szKey[wcslen(pVerInfo->szKey) + 1];
VS_FIXEDFILEINFO *pFixedInfo = (VS_FIXEDFILEINFO *) roundpos(pVerInfo, pOffsetBytes, 4);
int pvMS = pFixedInfo->dwFileVersionMS;
int pvLS = pFixedInfo->dwFileVersionLS;
int loLS = LOWORD(pvLS);
int hiLS = HIWORD(pvLS);
int loMS = LOWORD(pvMS);
int hiMS = HIWORD(pvMS);
delete [] lpBuffer;
verStr.Format(_T("Version %d.%d.%d (build %d)"), hiMS, loMS, hiLS, loLS);
m_edtVer.SetWindowText(verStr);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.