I have been scratching my head a lot with that one:
Whether I call GetLicenseAllowedActivations() or GetLicenseAllowedDeactivations() I am getting the same value.
Same for GetLicenseTotalActivations() and GetLicenseTotalDeactivations(), I am getting the same value.
Note that the AllowedActivations and TotalActivations are the correct values that match what is on the dashboard. It is the AllowedDeactivations and TotalDeactivations that are not.
I am basically trying to display in my program how many activations I have left relative to the total number and same deal for the deactivations.
Furthermore, for some reasons, when there are no more deactivations left, DeactivateLicense() returns a LA_E_DEACTIVATION_LIMIT error on my “Try…Catch” but when I read the “status” variable, it is a LA_OK and yet it does not deactivate. I am expecting a LA_FAIL so at least I can indirectly tell the user that they have no more deactivation left but throwing that LA_OK collides with when there is actually some deactivation left.
I am a hobbyist programmer so I might be doing something wrong or there is actually a bug. I am using the latest SDK 3.29.0.
Any idea what I should do?
It seems that the discrepancy arises because you are retrieving the GetLicenseTotalDeactivations() value before deactivating the license, and then checking the TotalDeactivations value afterward from the dashboard. This sequence is likely causing the mismatch.
Regarding the error handling, LA_E_DEACTIVATION_LIMIT is returned by the DeactivateLicense() function when no more deactivations are allowed, while LA_OK could be returned by any other function. If DeactivateLicense() fails, IsLicenseGenuine() will return LA_OK. So, I recommend checking for LA_E_DEACTIVATION_LIMIT to inform the user that no more deactivations are left.
Thank you for your reply, however, I am still in the dark.
My problem is that DeactivateLicense() does not seem to return what is expected. If there are still deactivations left, I get LA_OK and everything is happy but when there are none left, it does not seem to return LA_E_DEACTIVATION_LIMIT but just crashes. If I read the exception code it does say ‘60’ but the status code itself says ‘0’.
That is the whole reason I tried to play with GetLicenseAllowedDeactivations() and GetLicenseTotalDeactivations() so I could calculate how many I actually left to not even let the user deactivate if there are none left and therefore avoid the crash.
Try
status = LexActivator.DeactivateLicense()
If LexActivator.DeactivateLicense() = LexStatusCodes.LA_OK Then
MsgBox("succes")
Else
MsgBox("nope")
End If
Catch ex As LexActivatorException
Debug.Print("Catch: " & ex.Code.ToString() & " Error message: " + ex.Message & " /// " & status)
End Try
The output shows:
Exception thrown: ‘Cryptlex.LexActivatorException’ in Cryptlex.LexActivator.dll
Catch: 60 Error message: The license has reached it’s allowed deactivations limit. /// 0
To address this problem effectively please make sure to:
Call DeactivateLicense() only once to prevent unexpected behaviour, you seem to have called it multiple times in your code.
Use GetLicenseAllowedDeactivations() and GetLicenseTotalDeactivations() to determine if deactivations are still available before attempting to deactivate. This approach helps prevent exceptions by ensuring that you only call DeactivateLicense() when it’s safe to do so.
Ensure that exceptions are caught and handled gracefully.
Sorry that was a typo, I simplified the code for the sake of the demonstration but I messed up my copy/paste. I simplified even further to not confuse you:
Try
Debug.Print(LexActivator.GetLicenseAllowedDeactivations() & " / " & LexActivator.GetLicenseTotalDeactivations())
status = LexActivator.DeactivateLicense()
Debug.Print(" crash before getting here" & status)
Catch ex As LexActivatorException
Debug.Print("Catch: " & ex.Code.ToString() & " Error message: " + ex.Message & " /// " & status)
End Try
Output:
25 / 1
Exception thrown: ‘Cryptlex.LexActivatorException’ in Cryptlex.LexActivator.dll
Catch: 60 Error message: The license has reached it’s allowed deactivations limit. /// 0
As you can see it crashes directly on the DeactivateLicense() instead of returning me the integer of LexStatusCodes.
LexActivatorException does get the ‘60’ integer though which is ‘LA_E_DEACTIVATION_LIMIT’.
Now once again to prevent that, I have been trying to:
Use GetLicenseAllowedDeactivations() and GetLicenseTotalDeactivations() to determine if deactivations are still available before attempting to deactivate.
But it does not work as you can see I get ‘25 / 1’ while it should be ‘21 / 21’
This is what I have on the your web dashboard:
It looks like things are mixed up… Like I said in my original post:
GetLicenseTotalDeactivations() actually returns GetLicenseAllowedActivations()
GetLicenseAllowedDeactivations() actually returns GetLicenseTotalActivations()
DeactivateLicense() doesn’t return status code. If it succeeds good, if not it throws an exception which you can catch and proceed accordingly. The license properties you get through LexActivator functions do not get it from server but local cache. So the values in local cache are updated on server sync hence they may not reflect the actual value.
Thank you for your reply.
The whole reason I was trying to read a status code was because of this:
I thought I was getting LA_OK and LA_FAIL like stated. It is fine, like both you said, I can just handle it in my try…catch.
Now regarding the potential bug, I don’t think it is a caching issue as my 21/21 has been like that for 12+ days. I added manually an extra activation and it reflected instantly when I ran my program.
Here is the output:
26 / 1
Exception thrown: ‘Cryptlex.LexActivatorException’ in Cryptlex.LexActivator.dll
Catch: 60 Error message: The license has reached it’s allowed deactivations limit. /// 0
So I am sorry but I getting mixed up values:
GetLicenseAllowedDeactivations() actually returns the value of GetLicenseTotalActivations()
GetLicenseTotalDeactivations() actually returns the value of GetLicenseAllowedActivations()