开发者

C# Serial Number Embedded within Program

I'm writing my own serial number verification/protection for a software I wrote.

Assuming the serial number verifi开发者_如何转开发er is using pattern matching...once the serial number is verified, how can I change the program itself so that it doesn't ask the user for a serial number any longer?

I really don't want to have to create a separate license file. Is there a way to embed this within the program itself? Or is the registry the only other option (besides online verification, etc.)


You shouldn't really attempt to edit the program itself - it'll break signatures/strong-naming, the exe/dll file will almost certainly be locked, and even if you shadow-copy: many users won't have permission to edit it in program-files (or as click-once).

Something external such as a license file or registry setting seems appropriate (unless you want to build the app at your server per-client).


Is there a way to embed this within the program itself?

If you're hinting at modifying the assembly, then it's possible*, You'd need to have two assemblies - one that's currently executing and one that you're modifying - because the executing assembly will be locked by the file system. And you'd need to reserve enough space to store whatever new value you intend to inject.

*To prove this to myself, I created a small executable with that simply writes the value of a string, and used a hex editor to alter the value of the string.

You'd need to be quite smart about what change you made, though, otherwise registering the software and then simply copying the modified binary to other machines would circumvent your registration process.

Storing registration details in the registry is probably a far easier solution.


Personally I always generate a unique key from the machines hardware and store this in the registry.

Here is a simple example of a unique key but you may need to expand it if you want separate keys for different versions of the software.

http://www.vcskicks.com/hardware_id.php


You could save the serial key that was entered to a file or registry, and just authenticate it whenever the user starts your application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜