Tuesday, September 11, 2012

Serial Key based installer


In the previous post we discussed about deploying an application on a client system with the help of installers. We have explored the inno setup compiler for the same in brief. Now let us make a serial key based installer( ie the installation is completed only when you provide a valid serial key) using innosetup compiler.

For this you will have to generate the script as mentioned in detail in previous post and before running the script (generated by inno setup) you will have to edit the code. That is when it asks do you want to compile the new script now ? select no as image below shows 



Now you can edit the script which is similar to pascal but a dedicated inno setup script.


There are two ways to make the installer ask for serial key

1. Under the [Setup] tag add UserInfoPage=yes and also write the event function CheckSerial  after the [code] tag. You can write the code for checking serial key within this function. Only these two things have to be added extra. Documentation of this function can be read here. For instance here i am checking whether the key is a 9 digit even number.



function CheckSerial (Serial: String): Boolean;
var

  CanContinue: Boolean;
  New_New:Longint;
   
begin
CanContinue:=False;
New_New:=1;
 New_New:=StrToIntDef(Serial,New_New);

  if(New_New mod 2 = 0) and (Length(Serial)=9) then  //simple check if the value 
                                                    //is a 9 digit even number
begin CanContinue:= True ;  end
else begin  CanContinue:=False; end;

WizardForm.NextButton.Enabled := CanContinue;  
Result:=CanContinue;


end;

2. You can create a new page for serial key validation which requires a few more steps.
Documentation on creating Custom Wizard Pages can be read here and here. A detailed description of the code is given side by side


[code]

//declaring global variables
var
  EditFields: array of TEdit;             //declaring an array of editfields to hold your serial key.
  PageToDisplaySerialKey: TWizardPage;    //declaring a custom wizard page  

//declaring constants that is used throughout the code
const
  
  NO_OF_FIELDS = 1;     //no of editfields you require . Here only 1 editfield is shown
  CHAR_PER_FIELD = 9;   // no.of characters per field

 //procedure that constantly checks for changes in editfields
procedure EditChange(From: TObject);
//declare variables used in this procedure
var
  I: Integer;
  CanContinue: Boolean;
  x:String;
  Can:Boolean;
  New_New:Longint;

begin
//initialize all variables
  CanContinue := False;
  Can:=False;
  x:='';
  New_New:=1;
  x:= EditFields[0].Text; //get the value in the editfield.. here only 1 edit field so index 0 
  New_New:=StrToIntDef(x,New_New); // in this installer i allow only numbers as key, so converting string to integer

   //in a for loop check whether 9 characters(CHAR_PER_FIELD) have been entered
  for I := 0 to GetArrayLength(EditFields) - 1 do
    if Length(EditFields[I].Text) < CHAR_PER_FIELD then
    begin
      CanContinue := False;
      Break;
    end
    else begin CanContinue := True; end;
    // if all characters are entered then validate the key. Here i am using a simple logic.. check whether the entered 99 didgit number
    //is even or not. If it is even proceed else disable the next button        
  if(Length(x)=(NO_OF_FIELDS *CHAR_PER_FIELD)) and CanContinue then 
    begin 
      if New_New mod 2 = 0 Then  
         begin Can:= True ;  end; 
    end;
  WizardForm.NextButton.Enabled := Can;
end;
    //designing the custom page
procedure SerialKeyPage;
var
  I: Integer;
  EditField: TEdit;
  Labels: TLabel;
  Width: Integer;
begin
  PageToDisplaySerialKey := CreateCustomPage(wpWelcome, 'Serial Key validation','');//where  wpWelcome is the predefined id for Welcome page
                                                                                    //http://www.jrsoftware.org/ishelp/index.php?topic=scriptpages

  Labels := TLabel.Create(PageToDisplaySerialKey);
  Labels.Parent := PageToDisplaySerialKey.Surface;
  Labels.Caption := 'Provide a valid serial number and continue with the installation process';  //caption that appears on the page
  SetArrayLength(EditFields, NO_OF_FIELDS);
  Width := (PageToDisplaySerialKey.SurfaceWidth - ((NO_OF_FIELDS - 1)*5)) div NO_OF_FIELDS; //not necessary now since we have only 1 field
                                                                                            
        // a loop isn't necessary as now we have only 1 field but else useful
  
    EditField := TEdit.Create(PageToDisplaySerialKey);
    EditField.Top := 110;   //space on top of the editfield
    EditField.Width := Width;
    EditField.OnChange := @EditChange; //execute the  EditChange procedure everytime the text changes
    EditField.MaxLength := CHAR_PER_FIELD;//allows only this much characters 
    EditField.Parent := PageToDisplaySerialKey.Surface;
    EditFields[0] := EditField;
 
end;

procedure CurPageChanged(PageID: Integer);
begin
//if the current page is the custom page diable next button initially and enable only when key is correct
  if PageID = PageToDisplaySerialKey.ID then
    WizardForm.NextButton.Enabled := False;  
end;

procedure InitializeWizard;
begin
//shows the serial key page after the welcome page
  SerialKeyPage;
  end;


Once you finish editing the script  compile the code as shown in these   figures and save this script for later verification.



This is the welcome screen that appears first when you compile the code















         
FIGURE 1                                                                                                                                FIGURE 2

FIGURE 1 is the screen that appears if you made use of the first approach and FIGURE 2 is the result of second approach.

Software License for InnosetUp

57 comments:

Buzzinga said...

very useful information.

aparna said...

Thank you Buzzinga

Dev said...

Hi Aparna

Thank you for providing this tutorial.Can you please tell me how to generate serial key like one time password so that user can use serial key only once for one installation after one use key shld be destroyed.

srikanth bc said...

Iam very much interest to take training on online coaching on pega..for this i recommended you to this is a good online training on diffrent modules.

the best pega Online Training training

tom smith said...

It was nice to see the best online training for

Datastage Tutorial

kamal sharma said...

In java we need of guidance and these types of blogs always guide us.thanks for sharing it.
Best Java Training Institute In Jaipur



Enrique K Hazelton said...

very good infromation and thanks for sharing this keepitup.
JAVA Online Tutorials

Enrique K Hazelton said...

very good infromation and thanks for sharing this keepitup.
JAVA Online Tutorials

ramesh gollapally said...

Thanks for sharing fabulous information.It' s my pleasure to read it.I have also bookmarked you for checking out new posts.
Digital Marketing Training in Hyderabad


kits online said...

very nice article.Thanks for sharing the post...!
Microsoft Azure Online Training

Anonymous said...

Really useful information, 100% run successfully.

Thanks, a lot !

Your every article which I like to read no more searches required to do.


Thanks ! again.

Sandhya Blogger said...

Aparna photos

Sandhya Blogger said...

Aparna images

Naviya Nair said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

Priya Kannan said...

Great post! I am see the programming coding and step by step execute the outputs.I am gather this coding more information. It's helpful for me my friend. Also great blog here with all of the valuable information you have.
PEGA Training in Chennai

sunitha vishnu said...

It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
Android Training in Chennai
Ios Training in Chennai

Ram priya said...

This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
Data Science training in marathahalli
Data Science training in btm
Data Science training in rajaji nagar
Data Science training in chennai
Data Science training in kalyan nagar
Data Science training in electronic city
Data Science training in USA

vijay antony said...

This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.

rpa Training in Chennai

rpa Training in bangalore

rpa Training in pune

blueprism Training in Chennai

blueprism Training in bangalore

blueprism Training in pune

iot-training-in-chennai

vijay antony said...

This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.

rpa Training in Chennai

rpa Training in bangalore

rpa Training in pune

blueprism Training in Chennai

blueprism Training in bangalore

blueprism Training in pune

iot-training-in-chennai

simbu said...

A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.

java training in chennai | java training in bangalore

java training in tambaram | java training in velachery

java training in omr | oracle training in chennai

Jeyanthi R said...

Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…

Data Science training in marathahalli
Data Science training in btm
Data Science training in rajaji nagar
Data Science training in chennai
Data Science training in electronic city
Data Science training in USA
Data science training in pune
Data science training in kalyan nagar



Afiah B said...

Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
java training in chennai | java training in bangalore

java online training | java training in pune

sai said...

Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
python training in annanagar
python training in chennai
python training in chennai
python training in Bangalore

ragul ragul said...

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
Devops training in velachery
Devops training in annanagar
Devops training in tambaram
DevOps online Training

Unknown said...

myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

param jothi said...

Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this. 
Blueprism training in tambaram

Blueprism training in annanagar

Amazon Web Services said...

Hello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

Amazon Web Services Training in Pune | Best AWS Training in Pune

AWS Online Training | Online AWS Certification Course - Gangboard

Selenium Training in Chennai | Best Selenium Training in Chennai

Selenium Training in Bangalore | Best Selenium Training in Bangalore


cathryn leno said...

This is my 1st visit to your web... But I'm so impressed with your content. Good Job!
angularjs Training in bangalore

angularjs Training in btm

angularjs Training in electronic-city

angularjs online Training

angularjs Training in marathahalli

saimouni said...

Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
python training in velachery
python training institute in chennai

johnsy sai said...

Read all the information that i've given in above article. It'll give u the whole idea about it.
Devops Training in Chennai

Devops Training in Bangalore

Devops Training in pune

Anonymous said...

You’ve written a really great article here. Your writing style makes this material easy to understand.. I agree with some of the many points you have made. Thank you for this is real thought-provoking content
angularjs-Training in velachery

angularjs Training in bangalore

angularjs Training in bangalore

angularjs Training in btm

angularjs Training in electronic-city

angularjs online Training

Unknown said...

Nice blog..! I really loved reading through this article. Thanks for sharing such
a amazing post with us and keep blogging...Well written article Thank You for Sharing with Us project management courses in chennai | pmp training class in chennai | pmp training fee | project management training certification | project management training in chennai | project management certification online |

DJ PRASATH said...

Thanks for your post. This is excellent information. The list of your blogs is very helpful for those who want to learn, It is amazing!!! You have been helping many application.
best selenium training in chennai | best selenium training institute in chennai selenium training in chennai | best selenium training in chennai | selenium training in Velachery | selenium training in chennai omr | quora selenium training in chennai | selenium testing course fees | java and selenium training in chennai | best selenium training institute in chennai | best selenium training center in chennai

amsa leka said...

Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays.Well written article Thank You for Sharing with Us pmp training centers in chennai| pmp training in velachery | project management courses in chennai |pmp training in chennai | pmp training institute in chennai

pooja said...

Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
Best Devops online Training
Online DevOps Certification Course - Gangboard

tamilsasi said...

After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in



selenium training in Bangalore
selenium training in Marathahalli
selenium training in Btm layout
selenium training in Jaya nagar
selenium training in Electronic city
selenium training in Kalyan nagar



cathryn leno said...

I likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
python training in chennai
Python Online training in usa
python course institute in chennai

OLIVIA H said...

"Pretty excited to see that i have already accomplished everything in this blog when i came to go through this blog.So,i want to say simply thank u.
"
Authorized ipad service center in Chennai | Authorized apple service center in Chennai | iphone display replacement | Authorized ipad service center in Chennai | Authorized ipod service center in Chennai | Apple laptop service center in chennai | 100% genuine mobile parts | Mobile phone Battery replacement

shethal v said...

A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts read this.
devops online training

aws online training

data science with python online training

data science online training

rpa online training

jameel khan said...

Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
Microsoft Azure online training
Selenium online training
Java online training
Python online training
uipath online training

anusha said...



Python Training in ChennaiLearn Python Training in Chennai from industry experts and become a python certified professional.BITA is the Best Python Training Institute in Chennai which is located in ramapuram. Call for more details.

Jack Dorsey said...

QuickBooks has almost changed this is of accounting. Nowadays accounting has exploded in order to become everyone’s cup of tea and that’s only become possible because due to the birth of QuickBooks accounting software. We have the best plus the most convenient solution to boost your productivity by solving every issue you face with all the software. Give us a call at QuickBooks Support Number to avail the greatest customer care services made for you.

QuickBooks Payroll Support Phone Number said...

Why you ought to choose QuickBook Support The principal intent behind QuickBooks Support number would be to give you the technical help 24*7 so as with order in order to prevent wasting your productivity hours.

kevin32 said...

Most of us is responsible and makes certain to deliver hundred percent assistance by working 24*7 to meet your requirements. Go ahead and mail us at our
QuickBooks Tech Support Phone Number email id whenever you have been in need. You can reach us via call at our toll-free number.

rdsraftaar said...

As you know how important may be the QuickBooks payroll to boost your organization, you want the most effective and trustworthy QuickBooks Payroll assist to avoid facing technical glitches and learn many more new things like square QuickBooks integration and QuickBooks online accountant to really make the best utilization of this software using different tools. Just dial QuickBooks Payroll Tech Support to run this amazing accounting software without having any issue.

rdsraftaar said...

Let’s speak about our QuickBooks Enterprise Support Number USA that'll be quite exciting for you personally all. The advanced QuickBooks Desktop App for QuickBooks Support can now act as an ERP system good for medium scale businesses. QuickBooks Desktop Enterprise is not alike to pro, premier & online versions. Capacity and capability can be the reason behind this.

Quickbooks Enhanced Payroll Customer Support said...

QuickBooks Desktop Payroll Support Phone Number helps one to resolve all your valuable technical and functional problems whilst looking after this well known extensive, premium and end-to-end business accounting and payroll management software. Our experts team at QuickBooks payroll support number is going to make you understand its advanced functions and assists someone to lift up your business growth.

QuickBooks Payroll Support said...

QuickBooks Customer Technical Support Number, there's absolutely no part of wasting your own time, getting worried for the problem you will be facing and so forth. Just call and you'll get instant relief from the problem caused by various QuickBooks errors.

Mathew said...

For all for the company organizations, QuickBooks Tech Support Phone Number is actually and contains always been a challenging task to regulate the business accounts in an effective way by choosing the appropriate solutions.

kevin32 said...

While creating checks while processing payment in QuickBooks Payroll Tech Support Number online, a few that you've an effective record of previous payrolls & tax rates. That is required since it isn’t a facile task to create adjustments in qbo in comparison to the desktop version.

kevin32 said...

Are QuickBooks Enterprise Support Phone Number errors troubling you? Are you completely fed up with freezing of QuickBooks? If yes, afterward you have browsed off to the right place.

Bryan Willson said...

You may encounter QuickBooks Error 6000-301 when attempting to access/troubleshoot/open the company file in your QuickBooks. Your workflow gets hindered with a mistake message that says– “QuickBooks Desktop tried to get into company file. Please try again.”

Mathew said...

Our instantly QuickBooks Support team is perfect in taking down every QuickBooks Tech Support Number. We could assure you this with a warranty. Call our QuickBooks Support contact number. Our QuickBooks Support team will attend you.

jameswill11 said...

With exceptional features, QuickBooks Support helps most of the kinds of businesses with generating accounting reports, entries for every single sale, transactions pertaining to banking, etc., with a lot of ease. And along side support for QuickBooks, it really is much simpler to undertake all of the tools of QuickBooks in a hassle-free manner.

Quickbooks Enhanced Payroll Customer Support said...

QuickBooks Support Phone Number
QuickBooks has completely transformed the way people used to operate their business earlier. To get familiar with it, you should welcome this positive change. Supervisors at QuickBooks Support contact number have trained all of their executives to combat the issues in this software. Utilizing the introduction of modern tools and approaches to QuickBooks, you can test new techniques to carry out various business activities. Basically, this has automated several tasks that have been being done manually for a long time. There are lots of versions of QuickBooks and each one has a unique features. These versions are,

Rajesh said...

thanks for sharing this information
tableau training in BTM
tableau training in bangalore
tableau training in bangalore jayanagar
tableau training in bangalore btm
best tableau training institutes in bangalore
tableau classroom training in bangalore
Blue Prism Training in Bangalore
Blue Prism Training in BTM

accountingwizards said...

So, there is no point in wasting some time, getting worried when it comes to problem you will be facing and so forth. Just call QuickBooks Support Phone Number and you will get instant respite from the problem caused by various QuickBooks errors.