This is a very very basic example of how to make your program require a serial number.
Your serial number can be most anything you like within reason, it will be encrypted.
The crypted serial for this basic example will be inside your program.
if you want to use this examples serial it is "my serial"
It works like this.
1. Your program looks at a registry key value.
2. if the value does not exist or is wrong, the user will be asked for a serial.
3. if serial is correct, the regkey and value will be written to the registry and user will not be asked again because the next time they run it, the key and value will be there.
4. if serial is wrong, the program simply exits with a message.
This is a simple example and not intended to protect your program from attack/hack or anything else.
You should always be aware that the registry is used by your operating system, and is not to be played with.
Example using registry method
Here is an even more basic example using a folder existence method.