Summary
This article discusses how to create a serial number validation function using Delphi.Synopsis
This article discusses how to create a serial number validation function using Delphi. It provides a sample project that can be used as a reference.
Discussion
- Navigate to the Customize the Setup Appearance | Dialogs view.
- Select the Customer Information dialog.
- Select Yes as the value for the Show Serial Number property.
- Decide what the format will be for the valid serial number. For example, a serial number that uses the format ?????-#####, requires the user to enter 5 alphanumeric characters followed by 5 numeric characters. Add this to the Serial Number Template property.
- Build the serial number validation DLL in Delphi. The declaration of the serial number validation function should appear as follows:
function ValidateSerial(Wnd: HWND; SrcDir, SupportDir, SerialNum, Dbase: PAnsiChar): Longint; stdcall;The function should validate that SerialNum has the correct format and must return an integer value between 1 and 32767. Do not return 0 or values above 32767 because that causes the installation to terminate prematurely. The function should also be exported via the exports directive.
- Specify a value in the Success Return Value property. The value of this property must match the value returned by the ValidateSerial function. All other return values indicate an invalid serial number.
- After the DLL is built, select the DLL in the Serial Number Validation DLL property and specify the path to the serial number checking DLL.
- Set the Retry Limit property to a value.
- The Validate Function is the function name of the function exported by the DLL that does the actual serial number validation. It must adhere to the function signature as indicated above.
- The steps above will only allow the custom action to be called when the user has entered a serial number and clicks the Next button. However, during a silent install, the user does not click the button and consequently the serial number validation function doesn't get called.
In the attached sample code (SerialNumberValidation.zip), see the function ValidateSetup. ValidateSetup can be used in place of ValidateSerial if the setup needs to be run silently. The serial number can be entered by the user in the GUI but also via the command line. No matter how the serial number is entered, this custom action verifies it.
Create a new DLL custom action and call the DLL function ValidateSetup and the custom action DllValidateSetup. The name of the custom action should be different from the function name. Use the following property values:
Here are the other property settings for the DllValidateSetup custom action:
File Name: <ISProjectFolder>\CustomActions.dll
Function name: ValidateSetup
Function signature: ValidateSetup
Invoke: Before System Search (Silent Mode Only)
Wait for Action: Yes
Run Once: No
Execute: During Installation
Ignore Exit Code: No
Conditions: No ConditionsAlthough the invoke method is "silent mode only", the custom action also gets called if the user interface is visible. All custom actions should return a nonzero value to continue the installation or zero to abort.
- There are two support units in the sample code that ValidateSetup relies on:
- MSI contains a partial translation of msi.h and MsiQuery.h, which are part of the MSI API.
- MsiUtils contains wrappers around selected MSI API calls to make it easier to work with the MSI API.
- MSI contains a partial translation of msi.h and MsiQuery.h, which are part of the MSI API.
- GetMsiInstallationInfo is available in MsiUtils. This function can be used to retrieve the user name, company name, and serial number from the installation database.
- Note: InstallShield does not provide technical support for Windows programming or DLL debugging. You are responsible for correctly writing any DLL functions.
Additional Information
The sample project and content of this article was provided as a courtesy by user Tomatoman from the InstallShield Community group.
Related Articles
VBScript Custom Action : Compare Serial number With User Input 4Number of Views Use PowerShell to Create a Project and Add a PowerShell Custom Action Using the InstallShield Automation Interface 14Number of Views Activation of InstallShield 2010 using an AdminStudio 9.5 serial number results in Serial Number Not Registered Error 20661 7Number of Views Linking an asset to an inventory device without a serial number removes the asset serial number 7Number of Views Custom Action Does Not Load Interop.WUAPILib.dll 3Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago