Run Your Software only in known or specified Computer:
Read Code From Registry Editor Using C#
Now You only have to add a small Code in your Software to do so. The Code is given below... Again You have to run Visual Studio as Administrator.
{
int code;
RegistryKey software = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
RegistryKey regEx = software.OpenSubKey("RegDotNet", true);// Accessing a subdirectory RegDotNet in Directory "Software
if (regEx != null) // Codition to check nullity
{
RegistryKey sec = regEx.OpenSubKey("secret key", true);// Opening sizekey Subdirectory of RegDotNet
if (sec != null)// Condition to check nullti of size subdirectory
{
code = Convert.ToInt32(sec.GetValue("code").ToString());// getting value on width stored in "secret key" subdirectory
if (code == 123)// 123 is the Stored code
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
Now Call this Function in Constructor of the Application like this
public Form1()
{
InitializeComponent();
c = new calculations();// it is the object of another class in which calculations are done... no use in this Program
if (read_key() != true)
{
this.Close();
}}
OUTPUT:
The Application will be closed if code is not matched by the code that is saved by us in Store Secret Key on Registry Editor using C# ...
And if the code is matched .. the Application will run Normally.
Hit the Facebook like button below if you like this article... this helps a lot and keep us motivated :)
Hit the Facebook like button below if you like this article... this helps a lot and keep us motivated :)
