发一个原来写的写注册表的类,不过里面没有加密注册码,加密就自己研究吧
using System;
using Microsoft.Win32;
namespace WriteRegister
{
/// <summary>
/// Register 的摘要说明。
/// </summary>
public class Register
{
private static string mykey = "d3qz-a5ts-dje9-kkur";
public static bool IsRegisted()
{
if(Registry.LocalMachine.OpenSubKey("SOFTWARE\\RealtyManege") == null)
{
return false;
}
else
{
if((Registry.LocalMachine.OpenSubKey("SOFTWARE\\RealtyManege").GetValue
("key") != null &&
Registry.LocalMachine.OpenSubKey
("SOFTWARE\\RealtyManege").GetValue("key").ToString() == mykey))
{
return true;
}
else
{
return false;
}
}
}
public static bool Regist(string key)
{
if(key.ToLower() != mykey)
{
return false;
}
RegistryKey rk;
if ((rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\RealtyManege")) == null)
{
rk = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).CreateSubKey("RealtyManege");
}
rk.SetValue("key",key);
return true;
}
}
}