I've tried this technique before, but there's a chance it'll generate the same key/code more than once. Now, you could give the same key/code to more than one player, but in the end that would be the same as having one single license for everyone (and players could give the key to each other and play your game without paying).
You can also do it the way Scirra does it, and give a file (.txt file for instance) on purchase, and the buyer has to put that file into the program's director for the license to activate.
I'm also looking for a nice way to do serial codes and I'm not sure what I'll end up doing yet.