How to deactivate a license in VB.NET

The code below illustrates how to deactivate a license in VB.NET.

Private Sub ReleaseLicense()

    Dim lv As QLM.LicenseValidator

   ' settingsFile is the xml file generated by the Protect Your Application wizard
   lv = New QLM.LicenseValidator(settingsFile)

   Dim akey As String
   Dim ckey As String
   Dim compID As String
   Dim licenseBinding As ELicenseBinding

   akey = String.Empty
   ckey = String.Empty

   ' Update the license binding as needed
   licenseBinding = ELicenseBinding.ComputerName

   compID = lv.QlmLicenseObject.GetComputerID(licenseBinding)

   lv.QlmLicenseObject.ReadKeys(akey, ckey)

   If akey.Length > 0 Then
       Dim response As String
       response = String.Empty

       lv.QlmLicenseObject.ReleaseLicense("", akey, compID, response)

       Dim li As ILicenseInfo
       li = New LicenseInfo
       Dim message As String

       message = String.Empty

       If (lv.QlmLicenseObject.ParseResults(response, li, message) = True) Then
           lv.DeleteKeys()
           lv.UnpublishAnalyticsFromServer()
           MessageBox.Show(message)
        Else
           MessageBox.Show(message)
        End If
   Else
        MessageBox.Show("There is no license activated on this computer.")
   End If
End Sub

Last updated