| Function GetVerStr : String; Procedure SetVerStr( aVerStr : String ); public constructor Create; destructor Destroy; override; Procedure GetVersionFromFile( aFileName : String ); Function Compare( aVer : TMFileVersion ) : Integer; Property VerStr : String read GetVerStr write SetVerStr; End; { TMFileVersion } // init constructor TMFileVersion.Create; Begin Inherited; FMajor := 0; FMinor := 0; FRelease := 0; FBuild := 0; End; destructor TMFileVersion.Destroy; Begin Inherited; End; // Get version info from a file Procedure TMFileVersion.GetVersionFromFile( aFileName : String ); Type PVS_FIXEDFILEINFO = ^VS_FIXEDFILEINFO; Var h : Cardinal; // a handle, ignore nSize : Cardinal; // version info size pData : Pointer; // version info data pffiData : PVS_FIXEDFILEINFO; // fixed file info data nffiSize : Cardinal; // fixed file info size Begin FMajor := 0; FMinor := 0; FRelease := 0; FBuild := 0; If ( FileExists( aFileName ) ) Then FBuild := 1; nSize := GetFileVersionInfoSize( PChar( aFileName ), h ); If ( nSize = 0 ) Then Exit; GetMem( pData, nSize ); Try GetFileVersionInfo( PChar( aFileName ), h, nSize, pData ); If ( VerQueryValue( pData, '\', Pointer( pffiData ), nffiSize ) ) Then Begin FMajor := ( pffiData^.dwFileVersionMS ) SHR 16; FMinor := ( pffiData^.dwFileVersionMS ) AND $FFFF; FRelease := ( pffiData^.dwFileVersionLS ) SHR 16; FBuild := ( pffiData^.dwFileVersionLS ) AND $FFFF; End; Finally FreeMem( pData ); End; End; |