示例#1
0
        private void GenerateSmartButton_Click(object sender, System.EventArgs e)
        {
            StringBuilder    LicenseKeyBuff = new StringBuilder(1000);
            string           pNameEdit      = (this.NameEdit.Text.Length == 0)? null : this.NameEdit.Text;
            string           pOrgEdit       = (this.OrgEdit.Text.Length == 0)? null : this.OrgEdit.Text;
            string           pCustomEdit    = (this.CustomEdit.Text.Length == 0)? null : this.CustomEdit.Text;
            string           pHardIdEdit    = (this.HardIdEdit.Text.Length == 0)? null : this.HardIdEdit.Text;
            int              mNumDays       = (this.NumDaysEdit.Text.Length == 0)? 0 : Convert.ToInt32(NumDaysEdit.Text);
            int              mNumExec       = (this.NumExecEdit.Text.Length == 0)? 0 :  Convert.ToInt32(NumExecEdit.Text);
            int              SizeKey;
            sLicenseFeatures LicenseFeatures = new sLicenseFeatures();

            // set up license features

            LicenseFeatures.cb = Marshal.SizeOf(LicenseFeatures);

            if (this.ExpDateEnabledCheck.Checked)
            {
                LicenseFeatures.ExpDate.wYear  = (short)dateTimePicker1.Value.Year;
                LicenseFeatures.ExpDate.wMonth = (short)dateTimePicker1.Value.Month;
                LicenseFeatures.ExpDate.wDay   = (short)dateTimePicker1.Value.Day;
            }

            LicenseFeatures.NumDays = mNumDays;
            LicenseFeatures.NumExec = mNumExec;

            // generate SmartKey license

            SizeKey = WinlicenseSDK.WLGenLicenseDynSmartKey(LicenseHash, pNameEdit, pOrgEdit, pCustomEdit, pHardIdEdit, LicenseFeatures, LicenseKeyBuff);

            // show the generated key on the GUI

            SmartEdit.Text = LicenseKeyBuff.ToString();
        }
示例#2
0
        private void GenerateSmartButton_Click(object sender, System.EventArgs e)
        {
            StringBuilder LicenseKeyBuff     = new StringBuilder(1000);
            string        pNameEdit          = (this.NameEdit.Text.Length == 0)? null : this.NameEdit.Text;
            string        pOrgEdit           = (this.OrgEdit.Text.Length == 0)? null : this.OrgEdit.Text;
            string        pCustomEdit        = (this.CustomEdit.Text.Length == 0)? null : this.CustomEdit.Text;
            string        pHardIdEdit        = (this.HardIdEdit.Text.Length == 0)? null : this.HardIdEdit.Text;
            int           mNumDays           = (this.NumDaysEdit.Text.Length == 0)? 0 : Convert.ToInt32(NumDaysEdit.Text);
            int           mNumExec           = (this.NumExecEdit.Text.Length == 0)? 0 :  Convert.ToInt32(NumExecEdit.Text);
            SystemTime    ExpDateSysTime     = new SystemTime();
            SystemTime    NullExpDateSysTime = null;
            int           SizeKey;

            // get the current date from dateTimePicker1

            ExpDateSysTime.wYear  = (short)dateTimePicker1.Value.Year;
            ExpDateSysTime.wMonth = (short)dateTimePicker1.Value.Month;
            ExpDateSysTime.wDay   = (short)dateTimePicker1.Value.Day;

            // generate license file

            if (this.ExpDateEnabledCheck.Checked == false)
            {
                SizeKey = WinlicenseSDK.WLGenLicenseSmartKey(LicenseHash, pNameEdit, pOrgEdit, pCustomEdit, pHardIdEdit, mNumDays, mNumExec, NullExpDateSysTime, LicenseKeyBuff);
            }
            else
            {
                SizeKey = WinlicenseSDK.WLGenLicenseSmartKey(LicenseHash, pNameEdit, pOrgEdit, pCustomEdit, pHardIdEdit, mNumDays, mNumExec, ExpDateSysTime, LicenseKeyBuff);
            }

            // show the generated key on the GUI

            SmartEdit.Text = LicenseKeyBuff.ToString();
        }
示例#3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            StringBuilder PasswordBuffer = new StringBuilder(100);

            // generate password for specific user

            WinlicenseSDK.WLGenPassword(PasswordHash, this.NameEdit.Text, PasswordBuffer);

            // show password

            this.PasswordEdit.Text = PasswordBuffer.ToString();
        }
示例#4
0
        private void GenerateRegButton_Click(object sender, System.EventArgs e)
        {
            byte[]           LicenseKeyBuff  = new byte [4000];
            string           pNameEdit       = (this.NameEdit.Text.Length == 0)? null : this.NameEdit.Text;
            string           pOrgEdit        = (this.OrgEdit.Text.Length == 0)? null : this.OrgEdit.Text;
            string           pCustomEdit     = (this.CustomEdit.Text.Length == 0)? null : this.CustomEdit.Text;
            string           pHardIdEdit     = (this.HardIdEdit.Text.Length == 0)? null : this.HardIdEdit.Text;
            int              mNumDays        = (this.NumDaysEdit.Text.Length == 0)? 0 : Convert.ToInt32(NumDaysEdit.Text);
            int              mNumExec        = (this.NumExecEdit.Text.Length == 0)? 0 :  Convert.ToInt32(NumExecEdit.Text);
            int              SizeKey         = 0;
            string           RegName         = "HKEY_LOCAL_MACHINE\\" + this.RegNameEdit.Text;
            sLicenseFeatures LicenseFeatures = new sLicenseFeatures();

            // set up license features

            LicenseFeatures.cb = Marshal.SizeOf(LicenseFeatures);

            if (this.ExpDateEnabledCheck.Checked)
            {
                LicenseFeatures.ExpDate.wYear  = (short)dateTimePicker1.Value.Year;
                LicenseFeatures.ExpDate.wMonth = (short)dateTimePicker1.Value.Month;
                LicenseFeatures.ExpDate.wDay   = (short)dateTimePicker1.Value.Day;
            }

            LicenseFeatures.NumDays = mNumDays;
            LicenseFeatures.NumExec = mNumExec;

            // GenerateFileButton the Registry key

            SizeKey = WinlicenseSDK.WLGenLicenseRegistryKeyEx(LicenseHash, pNameEdit, pOrgEdit, pCustomEdit, pHardIdEdit, LicenseFeatures, RegName, this.RegValueNameEdit.Text, LicenseKeyBuff);

            // Create file to store the generated key

            FileStream fs = new FileStream(this.RegFileNameEdit.Text, FileMode.Create);

            BinaryWriter w = new BinaryWriter(fs);

            // Write data to file

            for (int i = 0; i < SizeKey; i++)
            {
                w.Write((byte)LicenseKeyBuff[i]);
            }

            // Close file

            w.Close();
            fs.Close();

            MessageBox.Show("A Registry file key has been generated", "Winlicense");
        }
示例#5
0
        private void GenerateRegButton_Click(object sender, System.EventArgs e)
        {
            byte[]     LicenseKeyBuff     = new byte [4000];
            string     pNameEdit          = (this.NameEdit.Text.Length == 0)? null : this.NameEdit.Text;
            string     pOrgEdit           = (this.OrgEdit.Text.Length == 0)? null : this.OrgEdit.Text;
            string     pCustomEdit        = (this.CustomEdit.Text.Length == 0)? null : this.CustomEdit.Text;
            string     pHardIdEdit        = (this.HardIdEdit.Text.Length == 0)? null : this.HardIdEdit.Text;
            int        mNumDays           = (this.NumDaysEdit.Text.Length == 0)? 0 : Convert.ToInt32(NumDaysEdit.Text);
            int        mNumExec           = (this.NumExecEdit.Text.Length == 0)? 0 :  Convert.ToInt32(NumExecEdit.Text);
            SystemTime ExpDateSysTime     = new SystemTime();
            SystemTime NullExpDateSysTime = null;
            int        SizeKey;
            string     RegName = "HKEY_LOCAL_MACHINE\\" + this.RegNameEdit.Text;

            // get the current date from dateTimePicker1

            ExpDateSysTime.wYear  = (short)dateTimePicker1.Value.Year;
            ExpDateSysTime.wMonth = (short)dateTimePicker1.Value.Month;
            ExpDateSysTime.wDay   = (short)dateTimePicker1.Value.Day;

            // generate license file

            if (this.ExpDateEnabledCheck.Checked == false)
            {
                SizeKey = WinlicenseSDK.WLGenLicenseRegistryKey(LicenseHash, pNameEdit, pOrgEdit, pCustomEdit, pHardIdEdit, mNumDays, mNumExec, NullExpDateSysTime, 0, 0, 0, RegName, this.RegValueNameEdit.Text, LicenseKeyBuff);
            }
            else
            {
                SizeKey = WinlicenseSDK.WLGenLicenseRegistryKey(LicenseHash, pNameEdit, pOrgEdit, pCustomEdit, pHardIdEdit, mNumDays, mNumExec, ExpDateSysTime, 0, 0, 0, RegName, this.RegValueNameEdit.Text, LicenseKeyBuff);
            }

            // Create file to store the generated key

            FileStream fs = new FileStream(this.RegFileNameEdit.Text, FileMode.Create);

            BinaryWriter w = new BinaryWriter(fs);

            // Write data to file

            for (int i = 0; i < SizeKey; i++)
            {
                w.Write((byte)LicenseKeyBuff[i]);
            }

            // Close file

            w.Close();
            fs.Close();

            MessageBox.Show("A Registry file key has been generated", "Winlicense");
        }
示例#6
0
        public Form1()
        {
            StringBuilder BufferVarValue = new StringBuilder(100);

            InitializeComponent();

            // We make the following call to allow testing in an unprotected state.
            // "LoadWinlicenseDll" will set up the environment variables with your custom valued in WinlicenseSDK.ini
            // NOTE: In your release version, before protecting, you have to REMOVE this call!!!

            // #if _DEBUG_MODE_
            WinlicenseSDK.WLLoadWinlicenseDll();
            // #endif

            // Check if application is Registered

            Kernel32.GetEnvironmentVariable("WLRegGetStatus", BufferVarValue, 100);

            if (System.Convert.ToInt32(BufferVarValue.ToString()) == 1)
            {
                MessageBox.Show("The application is already REGISTERED", "SmartKeys");
                System.Environment.Exit(0);
            }
        }