开发者

How Can I Let My Winform Work on a Single Machine Only? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

Improve this question

I have winform application written in c#. I would like this application to only gets installed in a single machine e.g. M1. If a user tries to install the application in M2, he/she will get an error says "installation aborted due to .... etc".

I will have to check MAC Address and Machine Name, if they match the one hard-coded in the application then carry on. Otherwise开发者_StackOverflow中文版, quit installation.

Any idea what steps should i take and where should i put this snippet?


Protecting your software with a combination of the machine name (you can change it easily) or a MAC address (you can create virtual network card with the MAC address you want easily), will not work long term.

I suggest you to use a HASP key:

http://www.aladdin.com/

Or authenticate online... this is cheaper, but your software has to be on the computer with an internet connection

And if protecting your software is really important to you, don't try to do it yourself. Use a professional solution. Here is one that do exactly what you want: http://www.eziriz.com/intellilock.htm


As to where you should put the code - put it in the program startup method:

public static void Main()
{
    if (licenced)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new YourForm());
    }
    else
    {
        // Display error
    }
}

as others have pointed out in their comments - it can be relatively easily removed, but if you're sure your user won't tamper with the code then it should do the job.

You could check the disk ID, CPU ID etc. See this Code Project article. Checking a combination would make it less likely that someone would be bothered to change all the values you are checking.

Though you would need access to the machine to get this information first and it will mean that if the user changes any of the hardware you check the program will stop working.


Assuming the user is completely non-technical, you could control all of this through configuration files. The first time the app runs, it gets the MAC address and machine name (like you want) and stores them in a file. The file should probably be encrypted. Every time the app starts up after that, it has to look at that file and ensure that the machine name it's running on and the MAC address of that machine match what is in the file.

This scheme could be broken by changing the MAC address or the machine name - it would cause the app to break. The scheme could be defeated if the file with the machine name/MAC address were given to other users who then changed their MAC address/machine name to match. There are probably other ways I haven't even thought of yet.

And since you ask where the code snippet should go, I'll say it should go near app startup, but without seeing your code it's really not possible to say more than that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜