TSTRING CVersion::GetSoftVersion()
{
TSTRING strVer = _T("");
TCHAR szPath[MAX_PATH] = _T("");
memset(szPath, 0, sizeof(szPath));
::GetModuleFileName(NULL, szPath, sizeof(szPath));
UINT nLenght = GetFileVersionInfoSize(szPath, 0);
if (nLenght != 0)
{
WCHAR *pBuf = NULL;
pBuf = new WCHAR[nLenght];
VS_FIXEDFILEINFO *pVsInfo;
if (GetFileVersionInfo(szPath, 0, nLenght, pBuf))
{
if (VerQueryValue(pBuf, (LPCWSTR)"\\", (void **)&pVsInfo, &nLenght))
{
wsprintf(pBuf, _T("%d.%d.%d.%d"), HIWORD(pVsInfo->dwFileVersionMS), LOWORD(pVsInfo->dwFileVersionMS), HIWORD(pVsInfo->dwFileVersionLS), LOWORD(pVsInfo->dwFileVersionLS));
strVer = pBuf;
}
}
delete pBuf;
}
return strVer;
}