Key registration (Very noooooob) (EDIT)

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.
7 posts Page 1 of 1
Contributors
User avatar
iLenkaa
Top Poster
Top Poster
Posts: 170
Joined: Mon Nov 01, 2010 1:17 pm

Hi guys,

I wanted to make a program with a key you have to fill in. But if you just take the easy way (like this):
Code: Select all
if textbox1.text = "thecode" or "theothercode" then
form2.show()
else
messagebox.show("Wrong code!")
Everytime you start up your little program, he'll ask the key again.
So thats, quite stupid.. :P
I found a (very weird) way to make him not ask it if you already filled the good key.
OMG. This english is really hard xD Sorry about that.

Uhmn yeah.
what did I do, I used 1 textbox and 1 button.

If you double-click the button, fill in this code:
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If TextBox1.Text = "thiscode" Then
            MkDir("C:\namedir\" + TextBox1.Text + "\")
            MsgBox("You succesfully registered this program.")
            Me.Hide()
            Form2.Show()
        Else
            ' If don't do anything.
        End If
        If My.Computer.FileSystem.DirectoryExists("C:\namedir\thiscode\") And TextBox1.Text = "" Then
            Me.Hide()
            Form3.Show()
        End If
    End Sub
It makes a directory when you filled in the right code. Everytime you'll starrt the program he'll check if that directory exist. If it doesn't, he'll ask for the key. So, as long as you don't delete the directory in :C\namedir\, he won't ask for the key.

With the following code, he'll check if the directory exists, when you start your program.
Code: Select all
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Computer.FileSystem.DirectoryExists("C:\namedir\thiscode\") Then
            ' If dir exist, show form2 and hide form1.
            Me.Hide()
            Form2.Show()
        Else
            ' Don't do anything.
        End If
    End Sub
Uhmn. It's quite stupid, but it works.
I only have a small problem, I wanted it to hide for 1 if he found the dir but he don't do it. I don't really understand why thats why you'll still have the form1.
You just have to click oK whitout entering the key.
I know it's hard to read :P So I hope you understand.
If you have a comment, i'll read it, but don't say stupid things like: your english sucks (i know) or your a noob (I am, i know). :P

Edit:
I the whole code to:
Code: Select all
Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If (Not (My.Computer.FileSystem.DirectoryExists("C:\naamvprogramma\geregistreerd\"))) Then
            ' Als de code nog niet werd ingegeven; vraag om de serial 
            Dim serial As String = ""
            While (Not (serial.Equals("12FZ-A269-5RK1-7SLL")))
                serial = InputBox("Geef a.u.b. de juiste key in:")
            End While
            ' de user heeft nu de juiste serial ingegeven -> maak de directory 
            MkDir("C:\naamvprogramma\geregistreerd\")
        End If
    End Sub
End Class
Don't watch the dutch text. I didn't have the time to change it to english.

Ilenkaa
Last edited by iLenkaa on Sat Nov 27, 2010 3:07 pm, edited 2 times in total.
Image
Image
Image
Image
Image
Image
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Nice work, I wanted to know how to make a file to create a text file and then load it. And you've helped me so I appreciate it.
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hey Ilenkaa
a very good Tutorial :)

nice one keep it up

Chris
Image
User avatar
iLenkaa
Top Poster
Top Poster
Posts: 170
Joined: Mon Nov 01, 2010 1:17 pm

Usman55 wrote:
Nice work, I wanted to know how to make a file to create a text file and then load it. And you've helped me so I appreciate it.
No problem! xD
Image
Image
Image
Image
Image
Image
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

is nice but this will work better if you use registry keys to store your code is much safer this way if you want to protect your more advanced programs.

Still very nice Tutorial Keep it up!
You can find me on Facebook or on Skype mihai_92b
User avatar
iLenkaa
Top Poster
Top Poster
Posts: 170
Joined: Mon Nov 01, 2010 1:17 pm

It's quite messy so I'll reorganize it when I find some time.
Image
Image
Image
Image
Image
Image
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

You could've used the Setting :/
7 posts Page 1 of 1
Return to “Tutorials”