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 variables 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 users 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 isnt 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\Softwa
re\Microso
ft\Interne
t 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\Softwar
e\Microsof
t\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\Softwar
e\Microsof
t\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