I used Rhino Licensing in the project (*) and it seems to cover most of your use cases. See Here for a tutorial, Rhino Code on GitHub , Direct Download of the Rhino Code (zip)
However, if someone is defined enough, then you can do nothing to stop them using your code
Rhino works by creating a license file for your users that has date-related information encoded in it. This is cryptographically signed, and the application code verifies that all is well. But all you need to win is to change your code to make a call to say whether the license was good or bad.
My solution for someone modifying my code is do it, as I will sign my code with a digital certificate that cannot be duplicated. So I can always say "Hey, here is the real code, and if your code does not match what someone did to change it?". There is a low level of fear, but you canβt do anything without standing in front of each user and forcing them to do something.
(*) I started with the base code, but then hacked the crap out of it to get what fit my desires.
source share