Co-incidently I wrote a small routine that may do what you're after, altho' you'd have have to provide the license key before the software was unencrypted. (ie if you wanted to protect you're software you may have to turn it into crippleware.)
Its not foolproof, nothing is, but it may go 1/2 way to meet you're requirement. You can find the proof of concept code here.