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(); }
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"); }
public static extern void WLResetLicenseFeatures(sLicenseFeatures LicenseFeatures, int SizeStructure);
public static extern int WLGenLicenseDynSmartKeyW(string LicenseHash, string UserName, string Organization, string CustomData, string MachineID, sLicenseFeatures LicenseFeatures, StringBuilder LicenseBuffer);
public static extern int WLGenLicenseRegistryKeyW(string LicenseHash, string UserName, string Organization, string CustomData, string MachineID, sLicenseFeatures LicenseFeatures, string RegName, string RegValueName, byte[] LicenseBuffer);
public static extern int WLGenLicenseFileKeyExW(string LicenseHash, string UserName, string Organization, string CustomData, string MachineID, sLicenseFeatures LicenseFeatures, byte[] LicenseBuffer);