AnsiString __fastcall GetExeVersion(AnsiString FileName)
{
DWORD dwSize;
DWORD dwReserved;
LPVOID lpBuffer;
AnsiString version;
dwSize = ::GetFileVersionInfoSize(FileName.c_str(), &dwReserved);
lpBuffer = ::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize );
if( lpBuffer && ::GetFileVersionInfo(Application->ExeName.c_str(), 0, dwSize, lpBuffer )) {
LPVOID lpStr;
UINT dwLength;
::VerQueryValue( lpBuffer,
"\\StringFileInfo\\041103A4\\FileVersion",
&lpStr, &dwLength );
version = (LPTSTR)lpStr;
}
if(lpBuffer){
::HeapFree( ::GetProcessHeap(), 0, lpBuffer );
}
return version;
}
AnsiString __fastcall GetEasyExeVersion(AnsiString FileName)
{
AnsiString Version = GetExeVersion(FileName);
int Pos = Version.AnsiPos(".");
AnsiString Res = Version.SubString(1,Pos-1);
Version.Delete(1,Pos);
Pos = Version.AnsiPos(".");
if(3 <= Pos){
Res += "." + Version.SubString(1,Pos-1);
}else{
Res += ".0" + Version.SubString(1,Pos-1);
}
return Res;
}