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, quit installation.
Any idea what steps should i take and where should i put this snippet?
As to where you should put the code – put it in the program startup method:
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.