// ID line follows -- this is updated by SVN
// $Id$
-
-#include "StdAfx.h"
+#include <windows.h>
+#include <tchar.h>
+#include <assert.h>
+#include "coretypes.h"
#include "version.h"
/**
* @brief Return file version string.
* @return File version as string.
*/
-CString CVersionInfo::GetFileVersion() const
+String CVersionInfo::GetFileVersion() const
{
return m_strFileVersion;
}
* @brief Return private build number.
* @return Private build number as string.
*/
-CString CVersionInfo::GetPrivateBuild() const
+String CVersionInfo::GetPrivateBuild() const
{
return m_strPrivateBuild;
}
* @brief Return special build number.
* @return Special build number as string.
*/
-CString CVersionInfo::GetSpecialBuild() const
+String CVersionInfo::GetSpecialBuild() const
{
return m_strSpecialBuild;
}
* @brief Return company name.
* @return Company name.
*/
-CString CVersionInfo::GetCompanyName() const
+String CVersionInfo::GetCompanyName() const
{
return m_strCompanyName;
}
* @brief Return file description string.
* @return File description string.
*/
-CString CVersionInfo::GetFileDescription() const
+String CVersionInfo::GetFileDescription() const
{
return m_strFileDescription;
}
* @brief Return internal name.
* @return Internal name.
*/
-CString CVersionInfo::GetInternalName() const
+String CVersionInfo::GetInternalName() const
{
return m_strInternalName;
}
* @brief Return copyright info.
* @return Copyright info.
*/
-CString CVersionInfo::GetLegalCopyright() const
+String CVersionInfo::GetLegalCopyright() const
{
return m_strLegalCopyright;
}
* @brief Return original filename.
* @return Original filename.
*/
-CString CVersionInfo::GetOriginalFilename() const
+String CVersionInfo::GetOriginalFilename() const
{
return m_strOriginalFilename;
}
* @brief Return product's version number.
* @return Product's version number as string.
*/
-CString CVersionInfo::GetProductVersion() const
+String CVersionInfo::GetProductVersion() const
{
return m_strProductVersion;
}
* @param [in] Last two numbers for version number.
* @return Formatted version string.
*/
-static CString MakeVersionString(DWORD hi, DWORD lo)
+static String MakeVersionString(DWORD hi, DWORD lo)
{
- CString sver;
- sver.Format(_T("%d.%d.%d.%d"), HIWORD(hi), LOWORD(hi), HIWORD(lo), LOWORD(lo));
+ TCHAR ver[50];
+ _sntprintf(ver, countof(ver) - 1, _T("%d.%d.%d.%d"), HIWORD(hi),
+ LOWORD(hi), HIWORD(lo), LOWORD(lo));
+ String sver(ver);
return sver;
}
* This function returns version number given as a number in version info.
* @return Product's version number as string.
*/
-CString CVersionInfo::GetFixedProductVersion()
+String CVersionInfo::GetFixedProductVersion()
{
if (!m_bVersionFound)
return _T("");
* This function returns version number given as a number in version info.
* @return File's version number as string.
*/
-CString CVersionInfo::GetFixedFileVersion()
+String CVersionInfo::GetFixedFileVersion()
{
if (!m_bVersionFound)
return _T("");
* @brief Return comment string.
* @return Comment string.
*/
-CString CVersionInfo::GetComments() const
+String CVersionInfo::GetComments() const
{
return m_strComments;
}
DWORD dwVerHnd = 0; // An 'ignored' parameter, always '0'
TCHAR szFileName[MAX_PATH];
- if (m_strFileName.IsEmpty())
+ if (m_strFileName.empty())
GetModuleFileName(NULL, szFileName, MAX_PATH);
else
- _tcsncpy(szFileName, m_strFileName, MAX_PATH - 1);
+ _tcsncpy(szFileName, m_strFileName.c_str(), MAX_PATH - 1);
DWORD dwVerInfoSize = GetFileVersionInfoSize(szFileName, &dwVerHnd);
if (dwVerInfoSize)
{
WORD codepage;
GetCodepageForLanguage(m_wLanguage, codepage);
- m_strLanguage.Format(_T("%04x"), m_wLanguage);
- m_strCodepage.Format(_T("%04x"), codepage);
+ TCHAR temp[20];
+ _sntprintf(temp, countof(temp) - 1, _T("%04x"), m_wLanguage);
+ m_strLanguage = temp;
+ _sntprintf(temp, countof(temp) - 1, _T("%04x"), codepage);
+ m_strCodepage = temp;
}
- else if (m_strLanguage.IsEmpty()
- || m_strCodepage.IsEmpty())
+ else if (m_strLanguage.empty()
+ || m_strCodepage.empty())
{
LANGUAGEANDCODEPAGE *lpTranslate;
DWORD langLen;
if (VerQueryValue((LPVOID)m_pVffInfo,
- _T("\\VarFileInfo\\Translation"),
- (LPVOID *)&lpTranslate, (UINT *)&langLen))
+ _T("\\VarFileInfo\\Translation"),
+ (LPVOID *)&lpTranslate, (UINT *)&langLen))
{
- m_strLanguage.Format(_T("%4.4X"), lpTranslate[0].wLanguage);
- m_strCodepage.Format(_T("%4.4X"), lpTranslate[0].wCodePage);
+ TCHAR temp[20];
+ _sntprintf(temp, countof(temp) - 1, _T("%4.4X"),
+ lpTranslate[0].wLanguage);
+ m_strLanguage = temp;
+ _sntprintf(temp, countof(temp) - 1, _T("%4.4X"),
+ lpTranslate[0].wCodePage);
+ m_strCodepage = temp;
}
}
QueryValue(_T("CompanyName"), m_strCompanyName);
* @param [in] szId Name of value/string to read.
* @param [out] Value read.
*/
-void CVersionInfo::QueryValue(LPCTSTR szId, CString& s)
+void CVersionInfo::QueryValue(LPCTSTR szId, String& s)
{
- ASSERT(m_pVffInfo != NULL);
+ assert(m_pVffInfo != NULL);
LPTSTR lpVersion; // String pointer to 'version' text
UINT uVersionLen;
BOOL bRetCode;
TCHAR szSelector[256];
- _sntprintf(szSelector, countof(szSelector), _T("\\StringFileInfo\\%s%s\\%s"),
+ _sntprintf(szSelector, countof(szSelector) - 1,
+ _T("\\StringFileInfo\\%s%s\\%s"),
m_strLanguage, m_strCodepage, szId);
bRetCode = VerQueryValue((LPVOID)m_pVffInfo,
szSelector,
if (bRetCode)
{
s = lpVersion;
- s.TrimLeft();
- s.TrimRight();
+ s = string_trim_ws(s);
}
else
- s.Empty();
+ s.clear();
}
/**
#define VERSIONTOOLS_H
#include <shlwapi.h>
+#include "UnicodeString.h"
/**
* @brief Class providing access to version information of a file.
WORD m_wLanguage; /**< Language-ID to use (if given) */
BOOL m_bVersionFound; /**< Was version info found from file? */
- CString m_strFileName;
- CString m_strLanguage;
- CString m_strCodepage;
- CString m_strCompanyName;
- CString m_strFileDescription;
- CString m_strFileVersion;
- CString m_strInternalName;
- CString m_strLegalCopyright;
- CString m_strOriginalFilename;
- CString m_strProductName;
- CString m_strProductVersion;
- CString m_strComments;
- CString m_strSpecialBuild;
- CString m_strPrivateBuild;
+ String m_strFileName;
+ String m_strLanguage;
+ String m_strCodepage;
+ String m_strCompanyName;
+ String m_strFileDescription;
+ String m_strFileVersion;
+ String m_strInternalName;
+ String m_strLegalCopyright;
+ String m_strOriginalFilename;
+ String m_strProductName;
+ String m_strProductVersion;
+ String m_strComments;
+ String m_strSpecialBuild;
+ String m_strPrivateBuild;
public:
CVersionInfo(BOOL bVersionOnly);
LPCTSTR szLanguage = NULL,
LPCTSTR szCodepage = NULL);
CVersionInfo(HINSTANCE hModule);
- CString GetFileVersion() const;
- CString GetCompanyName() const;
- CString GetFileDescription() const;
- CString GetInternalName() const;
- CString GetLegalCopyright() const;
- CString GetOriginalFilename() const;
- CString GetProductVersion() const;
- CString GetComments() const;
- CString GetSpecialBuild() const;
- CString GetPrivateBuild() const;
- CString GetFixedProductVersion();
- CString GetFixedFileVersion();
+ String GetFileVersion() const;
+ String GetCompanyName() const;
+ String GetFileDescription() const;
+ String GetInternalName() const;
+ String GetLegalCopyright() const;
+ String GetOriginalFilename() const;
+ String GetProductVersion() const;
+ String GetComments() const;
+ String GetSpecialBuild() const;
+ String GetPrivateBuild() const;
+ String GetFixedProductVersion();
+ String GetFixedFileVersion();
DLLVERSIONINFO m_dvi;
BOOL GetFixedFileVersion(DWORD &versionMS, DWORD &versionLS);
void GetVersionInfo();
void GetFixedVersionInfo();
void QueryStrings();
- void QueryValue(LPCTSTR szId, CString& s);
+ void QueryValue(LPCTSTR szId, String& s);
BOOL GetCodepageForLanguage(WORD wLanguage, WORD & wCodePage);
};