|
Crypt Library Demo 1.00
|
#include <VersionInfo.h>

Classes | |
| struct | TRANSLATION |
Public Member Functions | |
| CVersionInfo () | |
| ~CVersionInfo () | |
| BOOL | Load (LPCTSTR szFileName) |
| VS_FIXEDFILEINFO * | GetFixedFileInfo () |
| DWORD | GetFileFlagsMask () |
| DWORD | GetFileFlags () |
| DWORD | GetOS () |
| DWORD | GetFileType () |
| DWORD | GetFileSubType () |
| FILETIME | GetCreationTime () |
| unsigned __int64 | GetFileVersion () |
| unsigned __int64 | GetProductVersion () |
| CString | GetValue (const CString &sKeyName) |
| CString | GetComments () |
| CString | GetCompanyName () |
| CString | GetFileDescription () |
| CString | GetFileVersionAsString () |
| CString | GetInternalName () |
| CString | GetLegalCopyright () |
| CString | GetLegalTrademarks () |
| CString | GetOriginalFilename () |
| CString | GetPrivateBuild () |
| CString | GetProductName () |
| CString | GetProductVersionAsString () |
| CString | GetSpecialBuild () |
| int | GetNumberOfTranslations () |
| TRANSLATION * | GetTranslation (int nIndex) |
| void | SetTranslation (int nIndex) |
Protected Member Functions | |
| void | Unload () |
Protected Attributes | |
| WORD | m_wLangID |
| WORD | m_wCharset |
| ATL::CHeapPtr< BYTE > | m_VerData |
| TRANSLATION * | m_pTranslations |
| int | m_nTranslations |
| VS_FIXEDFILEINFO * | m_pffi |
Definition at line 38 of file VersionInfo.h.
| CVersionInfo::CVersionInfo | ( | ) |
Definition at line 52 of file VersionInfo.cpp.
: m_pffi(NULL), m_wLangID(0), m_wCharset(1252), //Use the ANSI code page as a default m_pTranslations(NULL), m_nTranslations(0) { }
| CVersionInfo::~CVersionInfo | ( | ) |
Definition at line 60 of file VersionInfo.cpp.
{
Unload();
}

| CString CVersionInfo::GetComments | ( | ) |
Definition at line 257 of file VersionInfo.cpp.
{
return GetValue(_T("Comments"));
}

| CString CVersionInfo::GetCompanyName | ( | ) |
Definition at line 212 of file VersionInfo.cpp.
{
return GetValue(_T("CompanyName"));
}

| FILETIME CVersionInfo::GetCreationTime | ( | ) |
Definition at line 156 of file VersionInfo.cpp.
| CString CVersionInfo::GetFileDescription | ( | ) |
Definition at line 217 of file VersionInfo.cpp.
{
return GetValue(_T("FileDescription"));
}

| DWORD CVersionInfo::GetFileFlags | ( | ) |
Definition at line 132 of file VersionInfo.cpp.
| DWORD CVersionInfo::GetFileFlagsMask | ( | ) |
Definition at line 126 of file VersionInfo.cpp.
| DWORD CVersionInfo::GetFileSubType | ( | ) |
Definition at line 150 of file VersionInfo.cpp.
| DWORD CVersionInfo::GetFileType | ( | ) |
Definition at line 144 of file VersionInfo.cpp.
| unsigned __int64 CVersionInfo::GetFileVersion | ( | ) |
Definition at line 165 of file VersionInfo.cpp.
| CString CVersionInfo::GetFileVersionAsString | ( | ) |
Definition at line 222 of file VersionInfo.cpp.
{
return GetValue(_T("FileVersion"));
}

| VS_FIXEDFILEINFO * CVersionInfo::GetFixedFileInfo | ( | ) |
Definition at line 120 of file VersionInfo.cpp.
| CString CVersionInfo::GetInternalName | ( | ) |
Definition at line 227 of file VersionInfo.cpp.
{
return GetValue(_T("InternalName"));
}

| CString CVersionInfo::GetLegalCopyright | ( | ) |
Definition at line 232 of file VersionInfo.cpp.
{
return GetValue(_T("LegalCopyright"));
}

| CString CVersionInfo::GetLegalTrademarks | ( | ) |
Definition at line 262 of file VersionInfo.cpp.
{
return GetValue(_T("LegalTrademarks"));
}

| int CVersionInfo::GetNumberOfTranslations | ( | ) |
Definition at line 252 of file VersionInfo.cpp.
{
return m_nTranslations;
}
| CString CVersionInfo::GetOriginalFilename | ( | ) |
Definition at line 237 of file VersionInfo.cpp.
{
return GetValue(_T("OriginalFilename"));
}

| DWORD CVersionInfo::GetOS | ( | ) |
Definition at line 138 of file VersionInfo.cpp.
| CString CVersionInfo::GetPrivateBuild | ( | ) |
Definition at line 267 of file VersionInfo.cpp.
{
return GetValue(_T("PrivateBuild"));
}

| CString CVersionInfo::GetProductName | ( | ) |
Definition at line 242 of file VersionInfo.cpp.
{
return GetValue(_T("Productname"));
}

| unsigned __int64 CVersionInfo::GetProductVersion | ( | ) |
Definition at line 174 of file VersionInfo.cpp.
| CString CVersionInfo::GetProductVersionAsString | ( | ) |
Definition at line 247 of file VersionInfo.cpp.
{
return GetValue(_T("ProductVersion"));
}

| CString CVersionInfo::GetSpecialBuild | ( | ) |
Definition at line 272 of file VersionInfo.cpp.
{
return GetValue(_T("SpecialBuild"));
}

| CVersionInfo::TRANSLATION * CVersionInfo::GetTranslation | ( | int | nIndex | ) |
Definition at line 277 of file VersionInfo.cpp.
{
ASSERT(nIndex >= 0 && nIndex < m_nTranslations);
AFXASSUME(m_pTranslations);
return &m_pTranslations[nIndex];
}

| CString CVersionInfo::GetValue | ( | const CString & | sKeyName | ) |
Definition at line 183 of file VersionInfo.cpp.
{
//Validate our parameters
AFXASSUME(m_VerData != NULL);
//What will be the return value from this function
CString sVal;
//Form the string to query with
CString sQueryValue;
sQueryValue.Format(_T("\\StringFileInfo\\%04x%04x\\%s"), m_wLangID, m_wCharset, sKey.operator LPCTSTR());
//Note that the definition for VerQueryValue in the VC 2005 Winver.h header file is incorrectly
//defined as taking a non-const 2nd parameter, so to avoid this issue, lets get a non const pointer
//to the "sQueryValue" buffer
LPTSTR pszQueryValue = sQueryValue.GetBuffer(sQueryValue.GetLength());
//Do the query
LPTSTR pVal = NULL;
UINT nLen = 0;
if (VerQueryValue(m_VerData, pszQueryValue, reinterpret_cast<LPVOID*>(&pVal), &nLen))
sVal = pVal;
//Release the non-const buffer now that we are finished with it
sQueryValue.ReleaseBuffer();
return sVal;
}

| BOOL CVersionInfo::Load | ( | LPCTSTR | szFileName | ) |
Definition at line 76 of file VersionInfo.cpp.
{
//Free up any previous memory lying around
Unload();
BOOL bSuccess = FALSE;
DWORD dwHandle = 0;
DWORD dwSize = GetFileVersionInfoSize(szFileName, &dwHandle);
if (dwSize)
{
//Allocate some memory to hold the version info data
ASSERT(m_VerData == NULL);
if (!m_VerData.Allocate(dwSize))
{
SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
if (GetFileVersionInfo(szFileName, dwHandle, dwSize, m_VerData))
{
//Get the fixed size version info data
UINT nLen = 0;
if (VerQueryValue(m_VerData, _T("\\"), reinterpret_cast<LPVOID*>(&m_pffi), &nLen))
{
//Retrieve the Lang ID and Character set ID
if (VerQueryValue(m_VerData, _T("\\VarFileInfo\\Translation"), reinterpret_cast<LPVOID*>(&m_pTranslations), &nLen) && (nLen >= sizeof(TRANSLATION)))
{
m_nTranslations = nLen / sizeof(TRANSLATION);
m_wLangID = m_pTranslations[0].m_wLangID;
m_wCharset = m_pTranslations[0].m_wCodePage;
}
bSuccess = TRUE;
}
else
TRACE(_T("CVersionInfo::Load, Failed to query file size version info for file %s, LastError:%d\n"), szFileName, ::GetLastError());
}
else
TRACE(_T("CVersionInfo::Load, Failed to read in version info for file %s, LastError:%d\n"), szFileName, ::GetLastError());
}
else
TRACE(_T("CVersionInfo::Load, Failed to get version info for file %s, LastError:%d\n"), szFileName, ::GetLastError());
return bSuccess;
}

| void CVersionInfo::SetTranslation | ( | int | nIndex | ) |
Definition at line 284 of file VersionInfo.cpp.
{
TRANSLATION* pTranslation = GetTranslation(nIndex);
m_wLangID = pTranslation->m_wLangID;
m_wCharset = pTranslation->m_wCodePage;
}

| void CVersionInfo::Unload | ( | ) | [protected] |
Definition at line 65 of file VersionInfo.cpp.
{
m_pffi = NULL;
if (m_VerData != NULL)
m_VerData.Free();
m_wLangID = 0;
m_wCharset = 1252; //Use the ANSI code page as a default
m_pTranslations = NULL;
m_nTranslations = 0;
}

int CVersionInfo::m_nTranslations [protected] |
Definition at line 88 of file VersionInfo.h.
VS_FIXEDFILEINFO* CVersionInfo::m_pffi [protected] |
Definition at line 89 of file VersionInfo.h.
TRANSLATION* CVersionInfo::m_pTranslations [protected] |
Definition at line 87 of file VersionInfo.h.
ATL::CHeapPtr<BYTE> CVersionInfo::m_VerData [protected] |
Definition at line 86 of file VersionInfo.h.
WORD CVersionInfo::m_wCharset [protected] |
Definition at line 85 of file VersionInfo.h.
WORD CVersionInfo::m_wLangID [protected] |
Definition at line 84 of file VersionInfo.h.
1.7.3