|
-
May 17th, 2012, 03:12 PM
#1
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
-
May 18th, 2012, 12:39 AM
#2
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.
Always use [code][/code] tags when posting code.
-
May 18th, 2012, 01:17 AM
#3
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..
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
May 18th, 2012, 02:45 AM
#4
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.
-
May 18th, 2012, 12:47 PM
#5
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.)
-
May 18th, 2012, 02:33 PM
#6
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.
Always use [code][/code] tags when posting code.
-
May 27th, 2012, 05:39 PM
#7
Re: Serial code
Id avoid the Dir function like a flesh eating plague.
You can use My.Computer.FileSystem.FileExists instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|