How to implement single instance per machine application?

前端 未结 7 2085
無奈伤痛
無奈伤痛 2020-12-06 17:42

I have to restrict my .net 4 WPF application so that it can be run only once per machine. Note that I said per machine, not per session.
I implemented single instance ap

7条回答
  •  执念已碎
    2020-12-06 18:08

    How about using the registry?

    1. You can create a registry entry under HKEY_LOCAL_MACHINE.
    2. Let the value be the flag if the application is started or not.
    3. Encrypt the key using some standard symmetric key encryption method so that no one else can tamper with the value.
    4. On application start-up check for the key and abort\continue accordingly.
    5. Do not forget to obfuscate your assembly, which does this encryption\decryption part, so that no one can hack the key in registry by looking at the code in reflector.

提交回复
热议问题