[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/28/2005 at 05:07PM PDT, ID: 21542981
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

How a Windows-based program compares a version number from a StringValue

Asked by BillDL in Windows Programming

Tags: version

Hello experts.

Q. How do most Windows-based programs perform a conditional check on what should be Numeric Values, but which are stored in the registry as String Values, eg. a "Version" number?  What I mean is, How is the data read?  Is it converted first?  Read on, and sorry it's so long - I think it's important to let experts know the background.

I realise that I have asked this question in the Windows Programming topic area, but let me stress that I AM NOT a fully-fledged programmer.  I know enough about variables and the Windows registry to allow me to do things from the command line and to follow what many Visual Basic or C source code does, but I've never got into it deeper.  In this instance I am using a program which provides an IDE that SHOULD allow me to create CD Autorun Menu's without any specific programming knowledge.

I compile CD-Autorun menu's using a program named "AutoPlay Menu Studio" by Indigo Rose (http://www.indigorose.com).  You won't find details of "AutoPlay MENU Studio" there, because I have version 2.5 which has long-since been superseded by "AutoPlay MEDIA Studio".  I do have version 4 of the "Media Studio" program, but it is a much more complex application with advanced levels that I really don't need.  You may well have seen CD-Autorun Menu's created in Autoplay Menu Studio when installing older Audio and Graphics drivers from the supplied CD. The presence of a "DATA" folder in the root of the drive containing MENU?.DAH, .DAL, and .DAW files (numbered sequentially), and a copy of the font(s) as MENU?.TTF are a giveaway that this was the application used to build the CD Autorun EXE.

The program IDE allows you to set up a project folder with all your resources, and then BUILDS the resources into a single .exe with the resources all wrapped up into program-specific data folder(s) and files used at runtime.  I have a feeling it builds them to use Visual C++ runtimes, but I can't be sure.

The IDE is quite simple, you just create a page (or multiple pages) and insert images and/or text to which you then apply  attributes.  It has some advanced features that allow you to show or hide objects dependent on certain conditions, and this is most commonly used where a registry key or value exists or is equal/not equal to the conditional value.

I am having problems with condition checks, but there's nothing in their "user forum" or FAQ that directly discusses my problem, and I have yet to receive a qualified answer from IndigoRose to my query.  The program's Help File only touches on using custom variables and conditions to check for the most basic kind of "If Exist" type of condition check, whereas I need to extend this a bit.  

The "Variable Manager" is a grid with five columns:

Variable =
The variable %NAME%.  There are inbuilt variables (see after)
Main key =
The main registry key to query for the "Value Name".
Sub key =
The sub key to query for the variable’s value
Value name =
The name of the value to get the data from.  If you want to get the "(Default)" value for a key, leave this field blank.  If you want to check for the existence of a key (as opposed to querying a value in the key), you can use the text **KeyExists** in this field.  This will cause the menu to return "Yes" if the key specified in Main Key and Sub Key exists or the Default value if it does not exist.
Default =
What to use if the value is NOT returned from the Registry.

Example: You want to check if a user’s system can view Adobe Acrobat files.  If it does, you want to hide the button that says "Install Adobe Acrobat Reader".  Otherwise, you want to show the button.

Create a custom variable in the Variable Manager and create the following conditions:

Variable = %AcrobatInstalled%
Main Key = HKEY_CLASSES_ROOT
Sub Key      = .pdf
Value Name = Leave Blank
Default = No

It reads the key "HKEY_CLASSES_ROOT\.pdf" from the Registry and stores the result in %AcrobatInstalled%.  If Acrobat documents are supported on the system, the [Default] value (in this case @="AcroExch.Document")  will be returned.  If the key can not be found (Acrobat isn’t supported), the default value "No" will be returned instead.

To set the "hide" condition for the "Install Adobe Acrobat Reader" button, enable condition checking and set the following values:

Value A      = %AcrobatInstalled%
Operator = Not Equal
Value B = No

So you can set up condtions for text or an image object, for a whole page, or for the entire menu, so that it is shown or hidden depenent on whether the condition is matched.

The application has these Built-In Variables:

%ColorDepth%
%LastPW% - The last password successfully entered
%OS% - Returns "Windows" for Win9x or "WindowsNT" for Windows NT
%ScreenHeight% - in pixels.
%ScreenWidth% - in pixels.
%SrcDrv% - Keeps pathss "relative", which is essential for CD's
%SrcDir% - Path that the menu .exe is run from
%SysDir%
%WinDir%

OK, so here's what I need to do from the aurorun CD Menu.
NOTE:  This is for MY use and not some commercial distribution, and just a means to allow me to upgrade other peoples' computers quite easily to more recent versions of freely available applications and utilities. This could obviously be extended for quick upgrades of Flash Player, Acrobat, DirectX, etc. where needed.  Forget about Licensing technicalities or valid upgrade paths for now, this is just a general question, and the methods would be applied to driver packages, etc, etc. :-)

1. Show a page that contains informational lines of text and button links that will run the setup.exe for one of the following : IE 5.0, IE5.01, IE5.5, IE6.0, IE6SP1 when clicked.

2. When the menu page loads, check the registry for the current version installed, and HIDE the non-applicable links and buttons.

I have 5 separate lines of informational text, and button links (that start the correct setup.exe) that I want to show or hide depending on the Internet Explorer version found to be installed.  Ideally I want the menu to ONLY show ONE of those lines of Info text, and then ONLY show the possible upgrades available.  I would then make the decision as to which one I run.  Something like this :

<fixed text> Version of IE Installed :

<info text1> Win98 FE version or older
<info text2> Win98 SE version
<info text3> 5.01
<info text4> 5.5
<info text5> 6.0
<info text6> 6 SP1 version

<fixed text> Upgrades Possible :

<link button1> Version 5.0
<link button2> Version 5.01
<link button3> Version 5.5
<link button4> Version 6.0
<link button5> Version 6 SP1
<link button5> No further IE upgrades possible
<fixed button6> Click to install Firefox :-)

Internet Explorer's Version is stored as:

[HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer]
"Version"=" "

The format of this value is the same for all versions of IE 5 as "x.xx.xxxx.xxxx", but version 6 uses "x.x.xxxx.xxxx".  To complicate things further, Version 4 uses a different format in Win95 OSR2 than Win98 First Edition, "x.xx.xxxx" and "x.xx.xxxx.x" (respectively).

Forget about versions older than the version installed by Windows 98 1st Edition, because IE6 isn't supported in Win95 anyway, and I can use the %OS% built-in Variable to disable the menu or the screen if it finds Win95.  Also forget about "Minimum Requirements" for now, as I will have to check this anyway.  This is just an example, and could be applied to programs other than IE.
Windows 2000, XP and XP-SP2 probably aren't going to allow this type of menu to query the registry anyway, so let's just assume this is targeted at Win98/ME machines, and the difference between the IE version installed by Win98 and Win98SE is enough to throw my condition check into a muddle.

Here's the Main versions, although I am aware that there are a number of different sub-versions :

IE4 installed by Win95 OSR2 = "4.70.1155"
IE 4.x installed by Win98 1st Ed = "4.72.3110.0"
IE 5.0 installed by Win98 SE = "5.00.2614.3500"
IE 5 installed by Win2K Pro = "5.00.2920.0000"
IE 5.01 upgrade = "5.00.2919.6304"
IE 5.5 installed by WinME = "5.50.4134.100"
IE 6.0 upgrade = version "6.0.2600.0000"
IE 6.0 installed by WinXP = version 6.00.2600.0000
IE6 SP1 = version "6.0.2800.1106"
IE6 SP1 installed by WinXPSP2 = version "6.00.2900.2180"

So, the condition check options to "Hide Object if condition is NOT met" are :

Value A - %CUSTOM1%
Operator - Choices: see below
Value B - ???

The program offers the "Operator" choices as :
Not Equal, Less Than, Less Than or Equal, Equal, Greater Than or Equal, Greater Than.

The options for creating a new custom variable are :

%CUSTOM1% = HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
Value Name = "Version"
Default value = "0" (ie. value returned if condition not met)

The problem seems to arise when specifying "Value B", and I am sure that this is due to the dots and the different format of the DataValue for the StringValue named "Version" in the registry.  Say I just want to check for the presence of a version older than IE 5.0, as would be the case on a Windows 98 First Edition PC, and show upgrade options from my CD Menu (just an example as I said before) :

Text to Hide/Show :
<info text1> "IE Win98 1st Ed version or older installed"
<info text2> "whatever"
etc. (There are another 4 lines with their own conditions set)

Buttons to Hide/Show (below all lines of text, and each with their own conditions) :
<button1> Upgrade to Version 5.0
<button2> Upgrade to Version 5.01
<button3> Upgrade to Version 5.5
<button4> Upgrade to Version 6.0
<button5> Upgrade to Version 6 SP1

Variable used in condition check for info text:
%IEVERSION% = HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
Value Name = "Version"
Default value = "0" (ie. value returned if condition not met)

Condition Check for <info text1> :
Value A - %IEVERSION%
Operator - Less Than or Equal To
Value B - "4.72.3110.0"

If TRUE ("Version" read from the registry indicates IE from Win98 1st Ed or Older), then I want to SHOW this text.
If FALSE ("Version" read from the registry indicates more Recent IE version and returns Zero), then I want to HIDE this text.

Conditional checks are applied individually to each of the "buttons" which will show or hide dependent on whether the condition is met or not. In the above example, I would HIDE ALL buttons EXCEPT <button1> (Upgrade to Version 5.0), because that would probably be my logical choice.
 
It would be simple if I just needed an exact match for the value, but the complication arises here because I really need to tailor the conditions to check if the version reported is Less Than, Less Than or Equal To, Equal To, Greater Than or Equal To, Greater Than, or Not Equal for the buttons and some of the text.  If, for example, the Version is read from the registry as "5.00.2614.3500" or more recent, then the format is different from "4.72.3110.0".

This seems to cause strange problems in whether the objects are shown or hidden, and I can only assume that it is because of the way that VALUE is being read from and returned from the registry.  Obviously IF "4.72" is read as a floating point numeric value, then it will be LESS Than "5.00" and should work, but HOW would most programs interpret a numeric value containing two more decimal places?

If it is read as an integer and disregards the decimal points, then a value of 47,231,100 (commas only shown to illustrate this) is still less than 50,026,143,500 and should work also.

When it compares IE 6 version numbers with IE5 ones, it doesn't work as intended, even though the equivalent integer values (if that is how it is read) still set IE5 as LESS THAN IE6:

5.50.4134.100 = 5,504,134,100
6.0.2600.0000 = 6,026,000,000

I HAVE tested the Less Than, Greater Than, etc operators using phony registry keys containing String Values purporting to be "Version" numbers, and it DOES work as long as my String Value is a series of numbers without any dots.

I set up several .reg files and imported them to the registry to change IE's version numbers for testing purposes.  The effects are strange, and it is showing lines of text which should not be shown, even though I have double-checked these variables thoroughly.  The ONLY time it works is when I set the conditions for an EXACT match and update the registry with the exact Version number set in the condition as an "If Equal To" or "If Not Equal To" situation.

What I am NOT sure of is whether this is a limitation of the program itself (which only provides some very limited single conditions for each object), or whether this is a more general issue where some type of conversion has to be done to a String Value before it is compared to something else.

Could somebody with direct programming knowledge advise me exactly HOW a value of this type IS read from the registry by Windows-based programs and is then interpreted.  This would help me to understand whether what I am trying to do in this program is actually possible.

Thanks in advance

Bill
 
Keywords: How a Windows-based program com…
 
Loading Advertisement...
 
[+][-]08/28/05 05:19 PM, ID: 14773186

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/02/05 05:53 AM, ID: 14809619

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Windows Programming
Tags: version
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09/02/05 07:19 AM, ID: 14810290

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/02/05 07:26 AM, ID: 14810383

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/02/05 09:09 AM, ID: 14811436

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/02/05 09:37 PM, ID: 14814937

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/02/05 09:41 PM, ID: 14814942

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/05 07:55 PM, ID: 14861424

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/05 10:52 PM, ID: 14861916

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/12/05 01:05 PM, ID: 14867108

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/13/05 03:40 AM, ID: 14870463

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/13/05 03:52 AM, ID: 14870497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91