private void btnProgram_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; LicenseFeatures features = LicenseFeatures.None; Array values = Enum.GetValues(typeof(LicenseFeatures)); for (int i = 0; i < clbFeatures.Items.Count; i++) { CheckState state = clbFeatures.GetItemCheckState(i); if (state != CheckState.Checked) { continue; } features |= (LicenseFeatures)values.GetValue(i + 1); } ushort writePass = 0xB838; ushort owp1 = 0xE39A; ushort owp2 = 0x03FB; LicenseLock ll = new LicenseLock(); ll.XyratexKeyNeeded = true; LicenseKeyCode code = ll.SetFeatures(features, writePass, owp1, owp2); this.Cursor = this.DefaultCursor; if (code == LicenseKeyCode.SUCCESS) { Notify.PopUp( "Successfully Programmed Features", "The following features were added: " + features.ToString(), "", "OK"); } else { Notify.PopUpError( "Failed Feature Programming", "Failed to program the current key. " + code.GetDescription(), ""); } }
/// <summary> /// Verifies the security dongle license (except for Xyratex developers). /// This releases and re-acquires the UltraPro license using our developerID and the specified designID. /// </summary> /// <param name="designId">The design id.</param> /// <returns>The <see cref="Authentication"/> result from the verification.</returns> public Authentication Verify(ushort designId) { if (!XyratexKeyNeeded) { // Check for user authentication WindowsIdentity identity = WindowsIdentity.GetCurrent(); if (identity.Name.StartsWith("XYUS\\", StringComparison.CurrentCultureIgnoreCase) || identity.Name.StartsWith("XY01\\", StringComparison.CurrentCultureIgnoreCase)) { _authentication = new Authentication(LicenseStatus.UserId, (LicenseFeatures)0xFFFF, LicenseKeyCode.SUCCESS); _authentication.Details = "Xyratex user enabled license."; return(_authentication); } } _authentication = new Licensing.Authentication(LicenseStatus.Failed, LicenseFeatures.None, LicenseKeyCode.UNIT_NOT_FOUND); int errCode = _ultraPro.SFNTsntlGetLicense(_developerId, designId, 0); if (errCode != Ultrapro.SP_ERR_SUCCESS) { LicenseKeyCode code = (LicenseKeyCode)errCode; _authentication = new Authentication(LicenseStatus.Failed, LicenseFeatures.None, code); _authentication.Details = "Key detection failed. " + code.GetDescription(); return(_authentication); } try { int keyIndex = designId; for (int i = 0; i < _designIds.Length; i++) { if (designId == _designIds[i]) { keyIndex = i + 1; if (i == _designIdSorterIndex) { _authentication = new Authentication(LicenseStatus.Key, LicenseFeatures.DEPO, LicenseKeyCode.SUCCESS); _authentication.Details = String.Format("Verified key ({0:X}).", keyIndex); return(_authentication); } break; } } uint data = 0; _ultraPro.SFNTsntlReadValue(_featureCellAddress, out data); LicenseFeatures keyFeatures = (LicenseFeatures)data; _authentication = new Authentication(LicenseStatus.Key, keyFeatures, LicenseKeyCode.SUCCESS); _authentication.Details = String.Format("Verified key ({0:X}).", keyIndex); return(_authentication); } finally { ushort userNum = 0; _ultraPro.SFNTsntlReleaseLicense(0, ref userNum); } }