Custom Serial Number Validation

For various reasons I hate InstallShield, and am willing to invest the extra effort in combining Orca with Visual Studio Deployment project to get the results I want.  Recently, I confronted the fact that the serial number validation that is available through the deployment project is extremely limited.

In my world, serial numbers are represented by Guids, validated by a central licensing server. My intent in ‘validating’ a serial number isn’t to actually determine that a given serial number will work, only to help the user ensure they haven’t made a typo when entering the number.  Hence, I append two more hex digits to the traditional Guid, that allows me to carry a checksum for the Guid, and help make sure the user really entered what they thought they entered.

Once I discovered that the basic validation stuff in a Visual Studio Deployment project wasn’t even strong enough to serve this need, I started rooting about on the web, assuming that others had bumped into this problem.  They had, and the majority of the posts referenced this – How To Validate a Serial Number During an Installation Created with VSI

Problem is, it doesn’t work exactly the same way with VS 2005 –  so here’s what you need to do to make it work.  The example of how to write the validator function itself is fine, so I’ll just deal with the Orca modifications at the end, where you’ll have to make some changes.

There’s two central things that have to be adjusted

1 – The name of the dialog is CustomerInfoForm, not UserNameForm – so all the instances of UserNameForm need to be changed to CustomerInfoForm

2 – It seems there’s some kind of undocumented side effect involved in calling ValidateProductID.  Try as I might, I could never advance to the next dialog if I didn’t call this, even if it were effectively a NOP.  So the other change I made to the instructions was to insert a new row that called my own validation function, after which I still called the (supposedly pointless) ValidateProductID

Below I’ve given the modified instructions that should work for you, as well as the exact table rows I’m using in the ControlEvent table

MODIFIED INSTRUCTIONS

7. Open the Microsoft Windows installer package (.msi) file that you built with VSI in Orca.
8. Add the DLL to the Binary table and name it VerifyPIDDll.
9. Add a new custom action to the Custom Action Table:
Name - MyPIDChecker;
Type - 1; Source - VerifyPIDDll; Target - VerifyPID
10. In the ControlEvent table, find the CustomerInfoForm , which corresponds to the Customer Information dialog box from VSI. Make all changes to the existing rows with CustomerInfoForm in the Dialog column and Next in the Control column:
a.

Insert a new row before the row that has the event ValidateProductID  and argument {}.  In the new row, set
Dialog column to CustomerInfoForm
Control to NextButton
Event to DoAction
Argument to MyPIDChecker
Condition to CustomerInfoForm_ShowSerial="1"
Ordering to 0

b. Since you’ve added a new row, you need to go through and increase all of the ordering values on the old rows by 1. 
c. Make sure that the value for the Condition column in the row with the EndDialog event is:
UserNameForm_NextArgs="" AND UserNameForm_ShowSerial=""
d. Using the PIDCHECK property which was set in the precious sample code, make sure that the value for the Condition column in the row with the NewDialog event is:
(PIDCHECK="TRUE") AND UserNameForm_NextArgs<>"" AND UserNameForm_ShowSerial<>""
e. Make sure that the value for the Condition column in the row with the [UserNameForm_ShowSerialDisabled] event is:
PIDCHECK="TRUE"
11. Save the .msi file and run the installation.

Modified ControlEvent Table

 Here’s what my customer information table rows look like – Note my names are slightly different than those in the instructions

 

Dialog Control Event Argument Condition Ordering
CustomerInfoForm NextButton ValidateProductID {} CustomerInfoForm_ShowSerial="1" 1
CustomerInfoForm NextButton EndDialog Return CustomerInfoForm_NextArgs="" AND (ProductID<>"" OR CustomerInfoForm_ShowSerial="0") 2
CustomerInfoForm NextButton NewDialog [CustomerInfoForm_NextArgs] (PIDCHECK="TRUE") AND CustomerInfoForm_NextArgs<>"" AND (ProductID<>"" OR CustomerInfoForm_ShowSerial="0") 3
CustomerInfoForm NextButton DoAction DoVerifyPID CustomerInfoForm_ShowSerial="1" 0
Published Sunday, August 27, 2006 1:09 PM by MarkMMullin
Filed Under:

Comments