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
Re: Serial system for applications
Posted: Fri Oct 02, 2009 1:03 am
by CodenStuff
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:
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:
Then inside the buttons click event code add this code:
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:
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 .
Heres the source files for this code if you want to see how it all works.
Download:
embededtrial30day.zip
Happy coding! cooll;
Re: Serial system for applications
Posted: Fri Oct 02, 2009 12:47 pm
by Diazepa
Welcome to Code'N'Stuff.com!
Re: Serial system for applications
Posted: Fri Oct 02, 2009 12:59 pm
by 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 )
rapidly the first line of the error wizard is
the chain conversion of "0" in type 'Date' is invalid.
Re: Serial system for applications
Posted: Fri Oct 02, 2009 4:02 pm
by CodenStuff
Hello,
I think its because you have "trialtime.AddDays(0)" set to "0" in this line:
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;
Re: Serial system for applications
Posted: Fri Oct 02, 2009 4:05 pm
by 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.
Re: Serial system for applications
Posted: Fri Oct 02, 2009 4:13 pm
by CodenStuff
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:
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;
Re: Serial system for applications
Posted: Fri May 28, 2010 1:59 pm
by GAMEKINGZ
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
Re: Serial system for applications
Posted: Fri May 28, 2010 2:15 pm
by dan2130
i dont understand
Re: Serial system for applications
Posted: Fri May 28, 2010 2:39 pm
by GAMEKINGZ
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.