FileVersion compare with stringvalue

delphi package - madRes, madTools, madStrings, ...
Post Reply
SteveO
Posts: 5
Joined: Fri Jun 24, 2005 8:59 am

FileVersion compare with stringvalue

Post by SteveO »

Hi madshi,

I'm using GetFileVersion from madTools to give me the version of a file. What I want to do is to compare the value of this to a value stored as a string in a database. You have a function FileVersionToStr which gives me a string in the form 1.0.0.0 What I'm wondering is how do I go the other way ie convert 1.0.0.0 to the format (int64) returned by GetFileVersion so I can do a compare ie if GetFileVersion < SomeFunction(1.0.0.0) then update file.
Not exactly a madTools question but maybe you have something done already that could be used,

Thanks,
SteveO
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Sorry for the late response! Somehow I missed this question...

You can convert such a string back to an int64 by doing this:

(1) Get the 4 number parts "1", "0", "0" and "0".
(2) An int64 has 64bits, that is 4x 16bit.
(3) Convert each of the (1) strings to a 16bit word.
(4) int64version := int64(word1) shl 48 + int64(word2) shl 32 + int64(word3) shl 16 + word4.
Post Reply