在软件中使用注册码 [英] Use Registration Key in Software

查看:92
本文介绍了在软件中使用注册码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现注册密钥的功能以使用软件,我所做的事情如下:-
我尝试了将密钥存储在注册表中并在应用程序启动时进行比较的概念


I want to implement functionality of registration key to use software what I have done is as follows:-
I tried on concept of storing key in registry and comparing the same on application start


private void Form1_Load(object sender, EventArgs e)//Main Form for application
        {
//Disable Application Menus
             if(CheckRegKey()==true)
             {
             //Enable Application Menus
             }
             else
             {
             MessageBox.Show("Please register to use the software.!!");
               Application.Exit();
               }

        }

private bool CheckRegKey()
        {
           bool data=false;
           
           int key=(int)Microsoft.Win32.Registry.GetValue("\\HKEY_CURRENT_USER\\Software\\Mysoft", "RegCode", 0);

        if(key==123456)
         {
         data=true;
          }
          return data;
        }







RegCode密钥的值在安装时由安装程序设置为0,因此用户无法使用软件,除非他:-
1)通过注册表格输入一个密钥,然后在与为程序选择的密钥(即123456
)进行核对之后,将该密钥RegCode的值写入注册表中







The value of the key RegCode is set to 0 by installer when it installs so user is unable to use software unless he:-
1)Enters a key through Register Form which writes the value of key RegCode in registry after checking with key chosen for program i.e 123456


//Registration Form
private void btnRegister_Click(object sender, EventArgs e)
if(Convert.ToInt32(txtRegCode.txt)==123456)
{
Microsoft.Win32.Registry.SetValue("\\HKEY_CURRENT_USER\\Software\\Mysoft", "RegCode",  Convert.ToInt32(txtRegCode.txt));
MessageBox.Show("Registration Successful!!");
}
else
{
MessageBox.Show("Registration Failed !!");
}
}




但是,这样做似乎有更好的方法,例如:-

1)密钥在程序中进行了硬编码,以便每次需要使用新密钥编译应用程序时都使用不同密钥,并且还需要重新创建其设置

2)当我们搜索键Mysoft




However this seems working is there a better way to do this as:-

1)The key is hardcoded in program to use diffrent keys everytime the application needs to be compiled with new key and also its setup needs to be created again

2)Key is visble in registry when we search key Mysoft

推荐答案

时,键在注册表中可见.这确实是一个好的开始.
如果您对商用软件有严重的业务需求,则购买现成的产品可能更简单.

但是,如果您是为了娱乐而编写代码,那么这是一个很好的概念.

这里的主要缺陷是您的软件为每个人使用相同的注册密钥.
如果有人拥有密钥,他可以在论坛上透露它,然后每个人都拥有它.

我相信您的首要任务是使每台机器或用户的密钥都不同.

这样一来,无需隐藏密钥,因为无论如何它都无法复制到另一台计算机.

我要做的是使用2个注册表项:

用户ID:pascal324234@gmail.com
RegCode:ASDFSDFSDFSDF

然后您可以检查密钥

This is indeed a good start.

If you have a serious business need on a commercial software it is probably simpler to buy an off the shelf product.

However if you''re coding for fun, this a good concept to work on.

The main flaw here is that your software use the same registration key for everybody.
If someone has the key, he could just divulge it on a forum and then everyone has it.

I believe your first task would be to make the key different for two every machine or user.

This way there are no need to hide the key as it can''t be copied to another machine anyway.

What I would do is use 2 registry keys:

UserId: pascal324234@gmail.com
RegCode: ASDFSDFSDFSDF

Then you can check the key

string registeredName; // read from registry
string actualRegistrationCode; // read from registry
string secretSeed = ":MantuSingh438";
string expectedRegistrationCode = (registeredName + secretSeed).GetHashCode().ToString("x");

if(expectedRegistrationCode == actualRegistrationCode)
{
         data=true;
}


这篇关于在软件中使用注册码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆