Product Key Management System
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
Thanks for reply, I have tried gmx for email and gmail - both didn't work. A Plus awardspace for ftp but it highlights: (Dosen't highlight try, just tell you what it's after)
Try
theClient.Send(theMailMessage)
And says: Smpt exception was unhandled
I checked over and I'm sure everything is right: Here is my code/Yours...:
Try
theClient.Send(theMailMessage)
And says: Smpt exception was unhandled
I checked over and I'm sure everything is right: Here is my code/Yours...:
Code: Select all
=-=- I don't think it ftp, it specificly highlights: theClient.Send(theMailMessage and I tried gmail and gmx. THANKS FOR QUICK RESPONSE< SORRY FOR MY LATE ONE! THANKS IN ADVANCE<><>CRICKETGDImports System.Net
Imports System.IO
Imports System.Net.mail
Imports System.Data
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rand As New Random()
Dim length As Integer
Dim randomString As String
length = rand.Next(15, 15)
randomString = ""
For i As Integer = 1 To length
randomString &= Chr(65 + rand.Next(20))
Next
Dim x As Integer
Dim randnum As New Random
x = rand.Next(10000000, 500000000)
TextBox3.Text = randomString
TextBox3.Text = TextBox3.Text + x.ToString
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MsgBox("Email address is blank")
ElseIf TextBox2.Text = "" Then
MsgBox("Username is blank")
End If
'Sends the email and attachment
Dim trialtime As Date = Now.AddDays(1)
Dim from As New MailAddress("xxxxxxx@gmx.com")
Dim [to] As New MailAddress(TextBox1.Text)
Dim theMailMessage As New MailMessage(from, [to])
theMailMessage.Body = "Thank you for purchasing " + ComboBox1.Text + vbNewLine + vbNewLine + "Your activation details are below." + vbNewLine + vbNewLine + "Username: " + TextBox2.Text + vbNewLine + vbNewLine + "Product Key: " + TextBox3.Text
theMailMessage.Subject = ComboBox1.Text + " Product Key"
Dim theClient As New SmtpClient("smpt.gmx.com")
theClient.UseDefaultCredentials = False
Dim theCredential As New System.Net.NetworkCredential("xxxxxxxx@gmx.com", "xxxxxxxxx")
theClient.Credentials = theCredential
theClient.EnableSsl = True
Try
theClient.Send(theMailMessage)
Catch wex As Net.WebException
MessageBox.Show("Could not send email...check your settings.")
End Try
MsgBox("E-mail successfully sent to:" + TextBox1.Text)
ComboBox2.Items.Add(TextBox2.Text)
My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\" + TextBox2.Text + ".usr", trialtime, False)
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\" + TextBox2.Text + ".act", TextBox3.Text, True)
My.Computer.Network.UploadFile(Application.StartupPath + "\" + TextBox2.Text + ".act", "ftp://www.dangerdeleter.awardspace.info/" + TextBox2.Text + ".act", "xxxxxxxxx", "xxxxxxxxxx", True, 10, FileIO.UICancelOption.DoNothing)
If My.Computer.FileSystem.FileExists(Application.StartupPath + "\" + TextBox2.Text + ".act") Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\" + TextBox2.Text + ".act", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
'ComboBox1.Items.Add(TextBox1.Text)
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\Accounts.act") Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\Accounts.act", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
With ComboBox2
Dim i As Integer
Dim s As String = ""
For i = 0 To .Items.Count - 1
s += .Items(i).ToString & vbNewLine
Next
My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\Accounts.act", s, False)
End With
MsgBox("Activation Key Successfully Uploaded")
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
If TextBox3.Text = "" Then
Button2.Enabled = False
Else
Button2.Enabled = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Retrieve file list from PlayList.txt file to ListBox1
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\Accounts.act") Then
Using sr As New IO.StreamReader(Application.StartupPath & "\Accounts.act")
Dim item As String = sr.ReadLine
While item <> Nothing
ComboBox2.Items.Add(item)
item = sr.ReadLine
End While
End Using
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\" + ComboBox2.Text + ".usr") Then
Using sr As New IO.StreamReader(Application.StartupPath & "\" + ComboBox2.Text + ".usr")
TextBox4.Text = sr.ReadLine
End Using
End If
Dim currentdatetime As Date = Now.AddDays(1)
Try
Dim url As String = "http://www.dangerdeleter.awardspace.info/" + ComboBox2.Text + ".act"
Dim pageRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
Dim pageResponse As WebResponse = pageRequest.GetResponse()
Dim page As String = ""
Using r As New StreamReader(pageResponse.GetResponseStream())
page = r.ReadToEnd()
End Using
If page = "****KEY-USED********KEY-USED****" Then
Label7.ForeColor = Color.Green
Label7.Text = "Activated"
Else
Label7.ForeColor = Color.Red
Label7.Text = "Not Activated"
If (currentdatetime > TextBox4.Text) Then
Button3.Enabled = True
End If
End If
Catch ex As Exception
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\" + ComboBox2.Text + ".act", "****KEY-USED****", True)
My.Computer.Network.UploadFile(Application.StartupPath + "\" + ComboBox2.Text + ".act", "ftp://www.dangerdeleter.awardspace.info/" + ComboBox2.Text + ".act", "xxxxxxxxxxx", "xxxxxxxxxx", True, 10, FileIO.UICancelOption.DoNothing)
If My.Computer.FileSystem.FileExists(Application.StartupPath + "\" + ComboBox2.Text + ".act") Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\" + ComboBox2.Text + ".act", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
If My.Computer.FileSystem.FileExists(Application.StartupPath + "\" + ComboBox2.Text + ".usr") Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath + "\" + ComboBox2.Text + ".usr", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
ComboBox2.Items.Remove(ComboBox2.Text)
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\Accounts.act") Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\Accounts.act", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
With ComboBox2
Dim i As Integer
Dim s As String = ""
For i = 0 To .Items.Count - 1
s += .Items(i).ToString & vbNewLine
Next
My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\Accounts.act", s, False)
End With
Button3.Enabled = False
MsgBox("Account has been deactivated!")
End Sub
End Class
Hello,
Change this line:
Change this line:
Code: Select all
To this: Dim theClient As New SmtpClient("smpt.gmx.com")
Code: Select all
That should do it ;)Dim theClient As New SmtpClient("mail.gmx.com")
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Code: Select all
The "isittrial" show up a error , "Isittrail" not declaredDim tcode = Convert.ToString(My.Settings.activated)
If (tcode = "1") Then
Button1.Visible = False
Else
isittrial()
End If
How to fix this?
Hello,
Have you included the "isittrial" sub code from the tutorial?
Have you included the "isittrial" sub code from the tutorial?
Code: Select all
Private Sub isittrial()
Dim trialtime As Date = Now
Dim currentdatetime As Date = Now
trialtime = trialtime.AddDays(30) 'SET THIS TO HOWEVER MANY DAYS YOU WANT THE TRIAL TO RUN FOR
Dim ttime = Convert.ToString(My.Settings.apptrial)
If (ttime = "1") Then
My.Settings.trialcode = trialtime
My.Settings.apptrial = "0"
My.Settings.Save()
End If
If (currentdatetime > trialtime) Then
Dim theSecondForm As New Activate()
theSecondForm.ShowDialog()
Me.Close()
End If
End Sub
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Ok , thanks i got it working
The best tutorial ever !
, keep on the good work CodenStuff


There's another problem occur , i activated one of my apps , then use the product key manager to kill the key , wehn i restart my app that key have been destroyed , it is still activated
What should i do ?
What should i do ?
and also , what happen if i activated this app , then i copy the activated app , will the copied app activated ?
question1: do i have to change the ftp://www.YOURSITE.com/ so its like ftp://www.name.0catch.com/ or should it be http://www.name.0catch.com/ ?
also when i try to use the product key, it says invalid key. its the exact same usrname and key that i generated and when it was being uploaded no error messages poped up so i don't know whats wrong.
also when i try to use the product key, it says invalid key. its the exact same usrname and key that i generated and when it was being uploaded no error messages poped up so i don't know whats wrong.
You said ;
"Now we need to enter 3 new settings in here so ill tell you the name of the setting and its value which you need to enter
apptrial - value = 1
trialcode - value = leave this blank
activated - value = 0
"
at settings, what is the value data type? string ,boolean, or ? and scope will be user or application?
Or we are going to enter this settings to Resources section? i don't figure out.
Also, when i use ClickOnce, whenever app updates it will require activation. am i wrong?
And thanks this code. it is good designed
Judasis
PS. I use vb 2008
"Now we need to enter 3 new settings in here so ill tell you the name of the setting and its value which you need to enter
apptrial - value = 1
trialcode - value = leave this blank
activated - value = 0
"
at settings, what is the value data type? string ,boolean, or ? and scope will be user or application?
Or we are going to enter this settings to Resources section? i don't figure out.
Also, when i use ClickOnce, whenever app updates it will require activation. am i wrong?
And thanks this code. it is good designed
Judasis
PS. I use vb 2008
Last edited by judasis on Sun Feb 14, 2010 9:43 am, edited 1 time in total.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023