2

I was looking for a serial script and I found one here:

CustomPage for Serial Number in Inno Setup

But how can I set the serial because all serials are valid now.

Thanks for your answer!

Community
  • 1
  • 1
  • 1
    Could you elaborate your question ? Did you mean how to pre-fill those fields ? Or how to check if all of those fields are filled ? – TLama Jun 28 '12 at 21:15
  • Sorry, I still don't get it for 100%. For instance RobeN (the OP of the question you've linked here) used for validation (for check if the serial number what user entered is correct) the external application. It's definitely upon you what algorithm will you use to validate your serial number. You can get the *serial number* built from what user entered by the `GetSerialNumber('-')` function there and you will get the serial number string delimited by the `-` char. Do you want to validate the serial directly in your setup script ? It wouldn't be so safe. – TLama Jun 29 '12 at 12:49
  • Can you give a code for example? I am completely new with Inno Setup. – notusedanymore Jun 29 '12 at 12:49

1 Answers1

5

Extending the code from my previous post, if you want to compare the serial number with a constant value, you can modify the script this way. The only valid serial number which allows users to continue will be 62FFU-GA4N8-T8N6W-WLQJW-N6WLQ-AJKD6:

procedure OnSerialEditChange(Sender: TObject);
var
  CanContinue: Boolean;
begin
  // the GetSerialNumber defined there returns you the serial number string
  // built from each edit box delimited by the char passed as a parameter
  CanContinue := GetSerialNumber('-') = '62FFU-GA4N8-T8N6W-WLQJW-N6WLQ-AJKD6';
  WizardForm.NextButton.Enabled := CanContinue;
end;

But note, it's not a good practice to store serial numbers as constants at all. You should consider to use another way to validate your product.

Community
  • 1
  • 1
TLama
  • 75,147
  • 17
  • 214
  • 392
  • I don't understand it. Should I paste this in my code? But thansk for taking your time! – notusedanymore Jun 29 '12 at 13:31
  • 1
    If I get you right you want to enable the next button only when the entered serial number matches to your serial number pattern, right ? In my original code there was used the validation for 5 chars, nothing more. If you paste this code (and replace the original code from the `OnSerialEditChange` event with the code from here), you will extend the validation for pattern, where each serial number segment must be 5 chars long and consists from 3 alphabetical chars and 2 numbers. – TLama Jun 29 '12 at 13:36
  • I mean that only 1 serial is valid and all the other combinations aren't valid. Looks like the password function in Inno Setup. – notusedanymore Jun 29 '12 at 13:43
  • For example, the next button will only enable when the follow code is filled: 62FFU-GA4N8-T8N6W-WLQJW-N6WLQ-AJKD6 – notusedanymore Jun 29 '12 at 14:00
  • Thanks!! Here I was looking for! You are my hero! – notusedanymore Jun 29 '12 at 14:21