Question How does Windows Installer determine a valid Product ID?
Many developers create .MSIs that require a product ID or serial number in order to prevent software piracy. The ProductID is a predefined Windows Installer property that contains the full product ID after a successful validation. On the User Information dialog, users enter a product ID or serial number provided by the vendor. Upon a successful validation, the ProductID property contains the number entered.
Windows Installer uses the ValidateProductID action or the ValidateProductID Control Event to evaluate the numbers entered based on a template stored in the PIDTemplate property. The template is designed by the developer of the .MSI during design time, and the MaskedEdit Control will appear on the User Information dialog according to the PIDTemplate. If the ValidateProductID action or ValidateProductID validates the PIDKEY entered by the user based on the PIDTemplate, then the ProductID is set and the .MSI continues to run the installation.
Windows Installer does not actually validate the value of the serial number. It only checks that the format of the value entered matches the format designed in the PIDTemplate. To evaluate the ProductID or serial number to determine if it is legal or valid, you need to add additional checking methods, such as a .DLL, using a custom action. The steps below provide an example of utilizing the ProductID feature with Windows Installer.
In a new .WSI, add one file using the Files page.
Navigate to Setup Editor, then Product Tab.
Select Properties in the left pane.
From the list of properties on the right, double-click PIDTemplate. Enter 12345<###-%%%-%%%>@@@ in the Value field.
Note: In this example, the # represents a digit; the % represents an alternate digit which is congruent to # except a custom action can be used to manipulate this character; The @ represents digits that are randomly selected by the Windows Installer. For a complete list of available characters, please refer to the Windows Installer SDK topic "MaskedEdit Control."
Delete ProductID from the property list.
Click the Dialogs tab.
Note: Steps 7 and 8 display the value to verify it is working properly. It is not necessary to include these steps in your production installation.
Select the Single Feature Destination dialog in the Welcome Dialog Wizard.
Right-click on Dialog and select Add > Text. Fill in the following information: Control Text: ProductID=[ProductID] and click OK.
Compile and run.
On the User Installation dialog, enter 123456105 in the Maskedit Control that defines the ProductID.
Click Next and, on the Single Feature dialog, you should see the following information displayed: ProductID=12345-123-456-105-890. Please make note that the 890 may be different for you because the last three digits are randomly chosen based on the PID TEMPLATE in this example.
Note: If you enter an invalid serial number, then when you click Next, an error appears rather than the next dialog.
This feature is useful to prevent software piracy. Users must enter a valid serial number to complete the installation. Windows Installer allows you to define a PIDTemplate in your .MSI, which it uses to validate entered serial numbers. If the serial number is valid, then the ProductID property is set and the installation can be completed. For more information on this feature, please see the Windows Installer SDK and search for "ProductID" under the Search tab.
If you need further customization to validate a ProductID, then you will need to create your own .DLL to handle the task.
Imported Document ID: HOWTO7987
Subscribing will provide email updates when this Article is updated. Login is required to Subscribe