This function will receive fileversion as a string:
function FileVersionGet( const sgFileName : string ) : string; var infoSize: DWORD; var verBuf: pointer; var verSize: UINT; var wnd: UINT; var FixedFileInfo : PVSFixedFileInfo; begin infoSize := GetFileVersioninfoSize(PChar(sgFileName), wnd); result := ''; if infoSize <> 0 then begin GetMem(verBuf, infoSize); try if GetFileVersionInfo(PChar(sgFileName), wnd, infoSize, verBuf) then begin VerQueryValue(verBuf, '\', Pointer(FixedFileInfo), verSize); result := IntToStr(FixedFileInfo.dwFileVersionMS div $10000) + '.' + IntToStr(FixedFileInfo.dwFileVersionMS and $0FFFF) + '.' + IntToStr(FixedFileInfo.dwFileVersionLS div $10000) + '.' + IntToStr(FixedFileInfo.dwFileVersionLS and $0FFFF); end; finally FreeMem(verBuf); end; end; end;
source share