Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

compare major version


5 replies to this topic

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 01 July 2004 - 18:53

I am trying to determine if my program is compatible with user's system. I am looking for a version of a file but only interested in its major version. How can I use VerCompare without including the minor version information.

VerGetFileVersion ( svValue ^ "winword.exe" , svVersionNumber );
nResult = VerCompare ("10.0", svVersionNumber, VERSION);

Thank you.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 02 July 2004 - 02:44

Well one way to do this would be to use the call StrGetTokens to break svVersionNumber at the decimal points to get a list of the major, minor, fix, build numbers. See the help for more information about then this call.

Then, at that point, you can just do a straight VerCompare of "10" to that 1st major token.
user posted image

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 02 July 2004 - 08:51

Another option would be to perform two comparisons to see if its in the range between 10.0.0.0 and 10.9999.9999.9999

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 02 July 2004 - 16:34

QUOTE (Taco Bell @ 2004-07-01 21:44)
Well one way to do this would be to use the call StrGetTokens to break svVersionNumber at the decimal points to get a list of the major, minor, fix, build numbers.  See the help for more information about then this call.

Then, at that point, you can just do a straight VerCompare of "10" to that 1st major token.

Thank you for the reply.

When I tried this method I was getting mixed results. When populating a list with the StrGetTokens I was getting the correct list (below).

10
0
6612
0

But when I tried to retrieve the first item I was getting weird results. Using "ListGetFirstItem" I always get "0" and using "ListGetFirstString" I would alwyas get "28579376".

I'm not sure what I'm doing wrong.

==========
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
szKey = "Software\\Microsoft\\Office\\10.0\\Word\\InstallRoot";
szName = "Path";
nType = REGDB_STRING;
RegDBGetKeyValueEx ( szKey , szName , nvType , svValue , nvSize );

VerGetFileVersion ( svValue ^ "winword.exe" , svVersionNumber );
listID = ListCreate (STRINGLIST);
StrGetTokens (listID, svVersionNumber, ".");

nResult = SdShowInfoList ("List Versions", "Test", listID);

ListGetFirstString (listID, svListString);
SprintfBox (INFORMATION, "List Item", "%i", svListString);
==========


vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 02 July 2004 - 16:52

QUOTE (Stefan Krueger @ 2004-07-02 03:51)
Another option would be to perform two comparisons to see if its in the range between 10.0.0.0 and 10.9999.9999.9999

This looks like an easier solution but I'm not sure how to limit the range though. It seems by doing both comparisons I am allowing incompatible versions to run.

nResult = VerCompare ( "10.0.0.0" , svVersionNumber , VERSION );

if (nResult = GREATER_THAN) then
szMsg = "The setup program was not able to determine that you have \n" +
"a compatible version of Microsoft Office installed.\n\n" +
"Click on the Next button to exit this program.";
MessageBox ( szMsg , WARNING );
szMsg = "The setup program will now exit.\n\n" +
"No files were installed in your system.";
MessageBox ( szMsg , INFORMATION );
abort;
elseif (nResult = LESS_THAN) then
nResult = VerCompare ( "10.9999.9999.9999" , svVersionNumber , VERSION );
if (nResult = GREATER_THAN) then
szMsg = "Version accepted";
MessageBox ( szMsg , INFORMATION );
endif;
endif;

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 02 July 2004 - 20:50

Well for your first attempt, the SprintfBox should be "%s", not "%i" because it's a string value and not a straight decimal value. 'cause remember all you've done is broken up the version string into a bunch of substrings.

For your second attempt, perform the two comparisons back to back (e.g. "10.0.0.0" and "10.9999.9999.9999" respectively) to get two results, then make sure nResult1 is not LESS_THAN and that nResult2 is not GREATER_THAN. This is to ensure that a version of say exactly "10.0.0.0" is properly accepted. Code wise, the comparison would work out to the following:

CODE
 nResult1 = VerCompare("10.0.0.0", svVersionNumber, VERSION);
 nResult2 = VerCompare("10.9999.9999.9999", svVersionNumber, VERSION);

 if (nResult1 != LESS_THAN && nResult2 != GREATER_THAN) then
   // VERSION ACCEPTED
   MessageBox("Version accepted.", INFORMATION);
 else
   // VERSION UNACCEPTABLE
   MessageBox("ERROR: Version unacceptable.", SEVERE);
 endif;

Hope it helps.
user posted image