C Hwang C Hwang - 3 months ago 32
C# Question

How to make C# executable file PC Specific

I am making a normal c# program and want it to be un-sharable. The way I want to approach this, is I have heard of code that could target and find the name of the user's pc. I have the name of my friend's PC, and want to have only work when he runs it.

The people I distribute it will inevitably try to copy and share it for another price, but I want to make a specific program for them every time that specifies only my buyer's desktop user name.

After some research I have been linked to here:

But I can't really make sense of it. Is there any function/line of code that straight gets the name of the user's pc and checks if it matches the pc I sold to? Thanks <3

Edit: When I am referring to the username, I am talking about the "Computer Name" under This PC > properties


You can easily verify the computer name using:

if(Environment.MachineName != "ComputerName")