示例#1
0
        private void A()
        {
            var A = new CryptoLicense
            {
                StorageMode = LicenseStorageMode.ToRegistry
            };

            A.ValidationKey = "AAAGgAGk/ESIIO4iJmXxVD/yH4xiLHGJIczm6SCvCAW157h/ew7tiYv/WJW0ug9nic4mf6y5GRywt0rBrFBL80Rb5otI+3AM79U669OUUIcdgP0tqaNSMUbAbLqXn6E/jispyo+R1LyUeKhNgk30iNJnto3C9LP6ASrQNA7jDWSQLWyrw94ztXc2vXSzzzpaRD0Jb3zWEqI9YY7QapnHMa/v0XI7pvK6aq46zgeZUP90yDbiHZjL7GU7R0qJOz8p3zI+6XPPKBohdfin9DcZ6QPJr9utB39wIJU6Mdx4i0acabWCGo1QeAmdUJ8Hvsc2EZ5Dpw0fFt2VfET4upf48aVpsx810oFJb4W70Y7+li5IO8Th9vcREF7OGaB1UasOppI5LCSEdgkv48r9PGldmkE58nAKjEBSp3MNVvhONMZrMPmozU/8YXttYEfmOxA7+5AaDLzJyJV5S38XC+4/0r7jOnezUggFGqjJ4gJIRXFHVMCcc8cRDQojYWzmKYloNF+2FlUDAAEAAQ==";
            if (!A.Load())
            {
                A.LicenseCode = "FgIkgTXjr2eZvNMBHgABbu29HnCHi267VJes6C+npz2IlKXxf3y6jv5STVfbfl6rU0s5pSByRT4ZclC9HYDwFg9TkLeIbowTpMNu+EFBVTILkovs7LfCIizYUZsfriR0sArMQCPzk5gP2dOdCK3Z+AyuovflkfissyJ+KAjDBYshohQ4yZdHIjPUhxA+TLc6mXv+GQTyrfFK/M1AFbJzj1km0UoeMhjRZ9SI2kh3bv5/QI8o18h9Fysa3aFRcVlGIi1ADHZGbcQK8XFzbicIyh1IVPoSRNtMzE3GeOQdzPL6YybM4+YQNIC+/yodUXbGUr9ldkMqTK7UoYtgTrTOgqJTOD/rPQrRQe4q5A40ZMSXtGu06tiZl+rfGzwlt9Aaalx8DGkV7Aixy2MGDNIxkVxIsVdmSP/BXLs9Qp8lPWpAGHG0nYZZr8iGNa9tpZ27lypQFrJdyrlYhL72vhcNlDSleR7Zn3AvyGJIvkKmzXwu/0f5bW/DAnhY7N49TmsR8LEjl7VHUallQ5ONI7iZ";
                A.Save();
            }

            if (!A.ShowEvaluationInfoDialog("Satış", "https://www.facebook.com/profile.php?id=100002547964778"))
            {
                Shutdown();
            }
            A.Dispose();
        }
示例#2
0
        public bool EvaluateLicense()
        {
            /*
             * This code demonstrates typically evaluation license scenario. The idea is as follows....
             * First you check if a full license is present (using CryptoLicense.Load method).
             * If .Load returns false, you switch to a hardcoded evaluation license code (using .LicenseCode property).
             * Then, you validate using .Status property.
             *
             * Even if user uninstalls, all the usage data associated which each license code remains in the
             * registry and if user reinstalls, the evaluation continues from where it left off.
             */
            var licenseValid = false;

            CryptoLicense license = CreateLicense();

            // The license will be loaded from/saved to the registry
            license.StorageMode = LicenseStorageMode.ToRegistry;

            // To avoid conflicts with other scenarios from this sample, the default load/save registry key is changed
            license.RegistryStoragePath = license.RegistryStoragePath + "EvalLicense";

            // The remove method can be useful during development and testing - it deletes a previously saved license.
            //license.Remove();

            // Another useful method during development and testing is .ResetEvaluationInfo()



            // Load the license from the registry
            bool loadDialog = !license.Load() || license.Status != LicenseStatus.Valid;

            if (loadDialog)
            {
                string dialogMessage = !license.Load()?"Licensing missing, enter the license key": license.Status != LicenseStatus.Valid?"Licensing expired, enter a new license key": "Licensing missing, enter the license key";
                // When app runs for first time, the load will fail, so specify an evaluation code....
                // This license code was generated from the Generator UI with a "Limit Usage Days To" setting of 30 days.
                LicenseForm licenseForm = new LicenseForm();
                licenseForm.labelMessage.Text = dialogMessage;
                if (licenseForm.ShowDialog() == DialogResult.OK)
                {
                    string licenseKey = licenseForm.textBoxLicense.Text;
                    license.LicenseCode = licenseKey;
                    // Save it so that it will get loaded the next time app runs


                    if (license.Status != LicenseStatus.Valid)
                    {
                        licenseValid = false;
                    }
                    else
                    {
                        license.Save();
                        licenseValid = true;
                    }
                }
                else
                {
                    Environment.Exit(0);
                }
            }

            if (license.Status != LicenseStatus.Valid)
            {
                licenseValid = false;
            }
            else
            {
                licenseValid = true;
            }



            return(licenseValid);

            // ShowEvaluationInfoDialog shows the dialog only if the license specifies evaluation limits
            if (license.ShowEvaluationInfoDialog("GrabCaster", "http://www.grabcaster.io") == false)
            {
                // license has expired, new license entered is also expired
                // or user choose the 'Exit Program' option
                licenseValid = false;

                // In your app, you may wish to exit app when eval license has expired
                Application.Exit();
            }
            else
            {
                // The current license is valid or the new license entered is valid
                // or the user choose the 'Continue Evaluation' option

                // If the user enters a new valid license code, it replaces the existing code
                // and is automatically saved to the currently specified
                // storage medium (registry in this sample) using the CryptoLicense.Save method.
                // The new license code is thus available the next time your software runs.

                // We still need to check whether the license is an evaluation license
                if (license.IsEvaluationLicense() == true)
                {
                    // reduce functionality in evaluation version if so desired
                    licenseValid = true;
                }
            }

            license.Dispose(); // Be sure to call Dispose during app exit or when done using the CryptoLicense object
            return(licenseValid);
        }