23 September, 2021

[VB] How to create program permissions in Visual Basic

Hello guys, sometimes if we create an application we definitely want to protect it from hijackers. In this article I will discuss how to create an activation program by reading the processor code on the device used, then performing the encryption process.

Now go back to Form1 and add the System.Management library. Right click on the project and select Add Reference, click on the .NET Tab then scroll down until you find System.Management and click OK

Image : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY8M-lZn7_UKO4Vuh0ZrPGQwYFVyK2AmETBqaLmHNzZzj5FmCIJX_fSGnv_gh8zOcxxm-pzhFzmaVSfh-vrveSANgLus8ZAHjZV8ksuP3JtY6tKf1HPhTB0At8XVDcIc-6OiCfL5zFl6U/s1600/management.png

Now go into the code and declare some necessary global variables

https://pastebin.com/bvxBfGUz

Then we will read the processor code on the device we use then we display it into Textbox1.
Double-click Form1 and enter the following code in Form_Load

https://pastebin.com/KvCM4PRC

And at the same time, the program will detect whether the device used is activated or not. Otherwise, the program will display a warning message and stay on Form1, if it is, Form1 will be hidden and Form2 will appear.

https://pastebin.com/M3yTXNkd

NOTE

some additional code above serves for the encoding of the processor code, then stored in the hasilenkripi variable.
then, the value of the hasilenkripsi variable will be stored in the Windows Registry Editor (Regedit) in the HKEY_CURRENT_USER folder.

Now, double-click Button 2 and enter the following code, so that the user can skip the activation process and enter Form2 but within a certain time.

https://pastebin.com/uUw9PTQn

Then double click Button 1 and enter the following code, to match whether the activation code entered in Textbox2 is equal to the value of hasilenkripsi variable. If appropriate, then Form1 will be hidden and Form2 will appear without time limit, otherwise it will display a warning message.

https://pastebin.com/z1sZEZzU

And finally, open Form2 and change the Timer1 properties to Enabled : True, Then double click on Timer1 and enter the following code.

https://pastebin.com/PmH3UWhU

NOTE

The above code works if Timer1 is enabled: True then Form2 can only appear for 5 seconds, If Timer1 is enabled: False then Form2 will appear without time limit.
You can change 5 seconds to 10 seconds (for example) by changing 50 to 100.

VIDEO DEMO : https://youtu.be/Ku-xoChi8M8

Good luck
All Right Reserved © 2015 By Hung Pro VN
Hung.Pro.VN Sharing Your Own Knowledge and Creative Thinking Every Day and Many Other Things.