Serial system for applications

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Serial system for applications
dan2130
Hi community , I dont know if this exist and free but i need a little system like the 30 day trial and activation service ...
but what i need is not like that what i need is a system when i program a couple of key only and no user name like the windows registration or other service becose i wanna distrubute my application with serial but i wanna not give an username fot all license sticker.

My key format would like the windows serial key :
FR4B7-G9VVC-PDKT6-HBHXY-DYDJ6 (its not valid windows key ... sorry )

thank in advance
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello dan2130,

I think I know what you mean, you want to embed the serial keys into your application and give them out to people without all the management stuff?.

If that is the case then you could do this. In the application you want to use this trial feature in click on "Project" in the menu bar at the top of VB and select "Yourproject Properties", then click the "Settings" tab and enter the following setting with its value:

Setting name: trial
Setting Value: first

Then go into your applications MAIN form, this would usually be "Form1" unless you have renamed it. Go into code-view and enter this code inside the "Form_Load" event:
Code: Select all
  Dim currentdatetime As Date = Now
        If Convert.ToString(My.Settings.trial) = "first" Then
            Dim trialtime As Date = Now
            trialtime = trialtime.AddDays(30) 'SET THIS TO HOWEVER MANY DAYS YOU WANT THE TRIAL TO RUN FOR
            My.Settings.trial = trialtime
            My.Settings.Save()
        End If
        If Convert.ToString(My.Settings.trial) = "fullversion" Then
            'DO NOTHING
        ElseIf currentdatetime > Convert.ToString(My.Settings.trial) Then
            Dim theSecondForm As New Form2()
            theSecondForm.ShowDialog()
            Me.Close()
        End If
You will notice that in this part of the code "Dim theSecondForm As New Form2()" you may need to change the word "Form2" to the name of the new form you will create in this next step. Thats all you need to do on your main form so save that and then you need to add a new form to your project by again clicking "Project" in the top menu and selecting "Add Windows Form".

Now you need to add 5 TextBox controls and 1 Button control to the new form. Layout the textboxs as follows:

TextBox1 TextBox2 TextBox3 TextBox4 TextBox5

And place the button underneath them so it looks something like this:

Image

Then inside the buttons click event code add this code:
Code: Select all
Dim serialkey = TextBox1.Text + "-" + TextBox2.Text + "-" + TextBox3.Text + "-" + TextBox4.Text + "-" + TextBox5.Text
        Select Case serialkey
            Case "123-abc-123-abc-123"
                My.Settings.trial = "fullversion"
                My.Settings.Save()
                MsgBox("Registration successfull.  Thank you.")
                Application.Restart()
            Case "123-456-123-456-123"
                My.Settings.trial = "fullversion"
                My.Settings.Save()
                MsgBox("Registration successfull.  Thank you.")
                Application.Restart()
            Case Else
                MsgBox("Invalid Key!.  Please check you have entered it correctly and try again.")
        End Select
That is the code where you will put your serial keys and I have started you off by adding 2 demo keys which you can change as you wish. You can add more if you want by simply adding a new "Case" statement to the group like:
Code: Select all
Case "POP-CORN-POP-CORN-POP"
My.Settings.trial = "fullversion"
My.Settings.Save()
MsgBox("Registration successfull.  Thank you.")
Application.Restart()
What this whole code does is it will set a 30-Day trial in your application the first time someone uses it and when the 30 days is over it will stop working and ask them to enter one of those serial keys in order to use it. Once a serial key has been entered correctly your application will run forever without trial :D .

Heres the source files for this code if you want to see how it all works.

Download:
embededtrial30day.zip
Happy coding! cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Diazepa
VIP - Donator
VIP - Donator
Posts: 70
Joined: Sat Sep 12, 2009 11:38 pm

Re: Serial system for applications
Diazepa
Welcome to Code'N'Stuff.com!
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: Serial system for applications
dan2130
Thanks for your rapidity you are the best !
But i have a little problem in the form 1 i dont know if that is related with my Visual basic 2008 or my windows xp pro french version but i post you a screenshot of my problem (sorry for the french error message )

Image

rapidly the first line of the error wizard is
the chain conversion of "0" in type 'Date' is invalid.
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello,

I think its because you have "trialtime.AddDays(0)" set to "0" in this line:
Code: Select all
trialtime = trialtime.AddDays(30) 'SET THIS TO HOWEVER MANY DAYS YOU WANT THE TRIAL TO RUN FOR
Im unable to replicate the error though. Try changing the value back to "30" and see if you get the error?.

Hope that helped cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: Serial system for applications
dan2130
it make the same thing with 30.
do you know how to remove the time function ?
example the costumer have no trial time and he have to register the aplication before first use it can be more simple.
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Hello,

Yes if you dont want the trial feature and want to ask for a key straight away just change all that "Form_load" event code to this:
Code: Select all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Convert.ToString(My.Settings.trial) = "fullversion" Then
            'DO NOTHING
        Else
            Dim theSecondForm As New Form2()
            theSecondForm.ShowDialog()
            Me.Close()
        End If
    End Sub
That will open the key window straight away everytime the application is run until a valid key is entered.

Happy coding! cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
GAMEKINGZ
Just Registered
Just Registered
Posts: 5
Joined: Fri May 28, 2010 1:48 pm

Thanks , i was looking for this one because i want that my programm needs a serial key before it can work.

also how can i make it possible to use more than only one specific serial ?

Greetz,
GAMEKINGZ
User avatar
dan2130
VIP - Donator
VIP - Donator
Posts: 104
Joined: Sat Sep 26, 2009 3:39 am

Re: Serial system for applications
dan2130
i dont understand
admin@adosrv.net
Owner of ado-srv.net softwares network.
User avatar
GAMEKINGZ
Just Registered
Just Registered
Posts: 5
Joined: Fri May 28, 2010 1:48 pm

dan2130 wrote:
i dont understand
well i read the main post twice and found my answer on my question.

i wanted to add more serials. but i found in main post so its solved now.

Greetz,
GAMEKINGZ
10 posts Page 1 of 1
Return to “Tutorial Requests”