RegistryKey licenseKey = Registry.CurrentUser.OpenSubKey("Software\\licDemo");但是我在注册表下没找到licDemo啊,怎么回事?

解决方案 »

  1.   

    没找到。。create是什么意思?
      

  2.   


    namespace licDemo
    {
        class RegLicenseProvider:LicenseProvider
        {
            public RegLicenseProvider()
            {
            }
            public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
            {
                if (context.UsageMode == LicenseUsageMode.Runtime)
                {
                    RegistryKey licenseKey = Registry.CurrentUser.OpenSubKey("Software\\licDemo");
                    if (licenseKey != null)
                    {
                        string strLic = (string)licenseKey.GetValue("LicenseCode");
                        if (strLic != null)
                        {
                            if (String.Compare(type.GUID.ToString(), strLic, false) == 0)
                            {
                                return new RuntimeRegLicense(type);
                            }
                        }
                    }
                    if (allowExceptions == true)
                    {
                        throw new LicenseException(type, instance, "许可证验证错误!");
                    }
                    return null;
                }
                else
                {
                    return new DesigntimeRegLicense(type);
                }
            }
        }
    }
      

  3.   

    明白了。。原来注册表授权就是要提前向注册表里写入值(2楼的create),不然不能使用。谢谢大家了。。