Why do you need example code of this specifically? Just find a library that allows you to download files from URL's, (e.g. curl, etc.) and gives an error when they are not present, and then use that to perform the exact thing you want to do. It's literally a ten-line piece of code and a ten-minute search on Google. If you can't find something that works yourself (or could be made to work), it makes me wonder what on EARTH you would ever write that I would subject myself to such copy-protection for.

But any such idea will be immediately bypassed by anybody with even half a brain within seconds, and just make people hate your software, to be honest.

What if your website goes down? What if you forget to renew the domain? What if the website is filtered or blocked accidentally by the company who bought the software? What if the Internet connection goes off and the company can't run your software? What if you get someone running thousands of copies of the software (which isn't taken account of by your system AND would flood your website if anyone did it)? What if you code it badly and it just doesn't work?

I am writing a game at the moment, which I intend to push for professional distribution of. As part of that, I wrote my own copy protection mechanism based on DNS records and X.509 certificate verification (including individual revocation of client certificates, licence expiry etc.). To be honest, I don't see it ever being used or implemented but it was a fun thing to code and took less than 24 hours to complete. It's really not that hard to do a decent job of it, but I know - even being the person that wrote it and designed that part specifically to make it difficult to work around - that someone with a modicum of experience and debugging tools would work around it in minutes if they were determined to.

I work in schools and, being a programmer on the side, I'm often asked to work around programs that try things like this. I've seen everything from online activation, to key generation dependent on system MAC addresses, to license verification done by hidden bytes in hidden sectors on a special master floppy disk that you HAVE to use to license computers individually (and how many computers even have a floppy drive any more?), to specialised expensive dongles by top-name companies. Every single one of them was worked around in an afternoon (but we never did, nor wanted to do, anything that breached the actual license we'd bought - just working around crappy copy protection that stopped us doing perfectly legitimate things, like work when the Internet goes off, or work when the floppy dies and the company does NOT send replacements). Literally, not one copy protection, mainstream nor unique customised handmade code, lasted longer than an afternoon without being able to be cracked so we could get rid of the restrictions. And every single one of them, we complained to the manufacturer and found alternatives when they were uncooperative.

Think what you are trying to achieve with this copy protection, and the impact it would have on your customers image of you should it go wrong. Because you're likely to do a lot more damage than anything else, and for little gain, and I assure you nothing you write will be "uncrackable" (hell, most of the professional stuff barely lasts a week before it's cracked!) by anybody who was determined to work around it. And if you can't even work out how to do it in five minutes of thinking and a quick Google, I'd be shocked if the code you end up with ever worked as intended.

But, most of all, if you think your code would be valued that much that people would tolerate such horrendous and amateur copy protection, I really think you're kidding yourself.