简体   繁体   中英

How to make windows application for single system(machine)

我想为桌面应用程序制作.exe,它一生只能使用一次,没有人可以运行两次。

You can not do that reliably.

You may try simple stuff like writing a magic key in the registry or storing a magic file somewhere, but simple tools like Process Monitor will show your magic markers to anyone with Google skills.

You may try to delete the .exe when it is terminating, but if the user makes a copy before they execute your file, you loose again.

You may write a root-kit that prevents the system from launching your application twice, but that is not very nice and it can be detected and circumvented too.

You may create an online service where your application needs check for a one time license to execute, but that can be cracked and you will get a big mess keeping track of one time licenses.

But in the end, if someone really wants to run your application more than once they will figure out how to do it.

How much protection do you want?

退出时自行删除?

What you are talking about is a single instance application that can start up, and no other copy can run - the single instance start up code is based on creating a mutex, and if another copy is run, it checks to see if the mutex is allocated, if it is, it bails out and exits immediately. Have a look at this article on CodeProject that does exactly what you're looking for.

It's possible to use a combination of DPAPI calls ( ProtectedData Class ) to push a value into the registry to check for a second time, or alternatively encode a value on first run and check the result matches the machine you intend it to be run on (and exit if not).

See DataProtectionScope.LocalMachine . The result of the protected data will be almost always different per machine, so this works as a specific-machine check.

You could create a registry key. If the key exists abort execution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM