-
Serial code
im wanting to make my program have to enter a serial and you dont have to enter anymore (Only once) if you want the full version, i have some code here, but i cant seem to get it to work properly, Can anyone help me? this is the last piece i have to do and its finished.
Code:
Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click
If KryptonTextBox1.Text = "" Then
MsgBox("Whoops! - Please make sure that all of the information with the * is filled out, and then try again!", MsgBoxStyle.Critical, "Whoops!")
Else
If KryptonTextBox1.Text = "N5869-N2201-N4859-N7832" Then
MsgBox("Thank you for registering, enjoy the full program! Noter will now restart to apply all changes!", MsgBoxStyle.Information, "Thank you!")
Form2.OptionsToolStripMenuItem.Enabled = True
Dim objStreamWriter As StreamWriter
'Pass the file path and the file name to the StreamWriter constructor.
objStreamWriter = New StreamWriter("C:\NoterPRO.txt")
'Write a line of text.
objStreamWriter.WriteLine("Serial encrypted")
'Close the file.
objStreamWriter.Close()
objStreamWriter.Close()
Dim retval As String
retval = Dir$("c:\NoterPRO.txt")
If retval = "Serial.txt" Then
Form2.OptionsToolStripMenuItem.Enabled = True
KryptonTextBox1.Text = "You have already registerd Noter!"
KryptonTextBox1.Enabled = False
KryptonButton1.Enabled = False
Application.Restart()
End If
End If
End If
End Sub
Code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim retval As String
retval = Dir$("c:\NoterPRO.txt")
If retval = "Serial.txt" Then
OptionsToolStripMenuItem.Enabled = True
Form3.KryptonTextBox1.Text = "You have already registerd Noter!"
Form3.KryptonTextBox1.Enabled = False
Form3.KryptonButton1.Enabled = False
End If
End Sub
-
Re: Serial code
It would help if you stated what it is not doing properly. Simply saying it does not work does not tell us much.
-
Re: Serial code
OUCH!!!
Looking over the code that you've posted here .. this is not much of a Serial Protection key system..
Firstly the Key file is stored in the C: Root.... Not wise... While by Default the Boot partition is C: there are some systems that are not setup this way..
Next, your not parsing the file correctly..
Code:
retval = Dir$("c:\NoterPRO.txt")
If retval = "Serial.txt" Then
Please check this MSDN page for how the DIR function works.. What you have here will NEVER resolve to True....
for a sample on how to implement this have a look at this thread..
-
Re: Serial code
I suggest not to use a single fixed hard-coded serial key!
It's called serial for a reason :)
Usually serial numbers are generated according to some scheme which also lets you check if a serial number is valid, like a checksum.
-
Re: Serial code
Its not retriving the key thats stored in C:\ its just ignoring it. (I know its not a good serial system, this is just a small program noting big, im not worried about it.)
-
Re: Serial code
As Gremlin pointed out above your code is way off
Code:
retval = Dir$("c:\NoterPRO.txt")
If retval = "Serial.txt" Then
OptionsToolStripMenuItem.Enabled = True
Form3.KryptonTextBox1.Text = "You have already registerd Noter!"
Form3.KryptonTextBox1.Enabled = False
Form3.KryptonButton1.Enabled = False
End If
The dir statement will return the name of the file you searched for or will be blank but you are comparing it to somethihng different so it will never match under any conditions.
You also are not reading the file nor checking the content.
-
Re: Serial code
Id avoid the Dir function like a flesh eating plague.
You can use My.Computer.FileSystem.FileExists instead.