how to make exe file work on one computer only

删除回忆录丶 提交于 2019-12-30 11:06:47

问题


I wrote a program using C# and make exe file using advanced installer and it work good but i want to make this exe file work in one computer, because some clints take exe and give this exe to another and i want to privint that and protect my works


回答1:


run the code below on the machine that you want your .exe. file to work on (it will give you this machines MAC address). 2. Add this MAC address to the code below 3. Add the code below to your C# code to ensure that it only runs on the machine with the correct MAC address (unique)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;

namespace OneMachine
{
    class Program
    {
        static void Main(string[] args)
        {

            string clientMAC = "XX-XX-XX-XX-XX-XX";       //  put the correct value here when you know it
            string thisComputerMAC = GetMACAddress2();

            Console.WriteLine("MAC:" + thisComputerMAC);   // remove this when necessary

            if (clientMAC == thisComputerMAC)
            {

                Console.WriteLine("this is the right computer");
            } else
            {
                Console.WriteLine("PROGRAM WONT RUN ON THIS COMPUTER");
            }


        }

        public static string GetMACAddress2()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            String sMacAddress = string.Empty;
            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty)// only return MAC Address from first card  
                {
                    //IPInterfaceProperties properties = adapter.GetIPProperties(); Line is not required
                    sMacAddress = adapter.GetPhysicalAddress().ToString();
                }
            } return sMacAddress;
        }


    }
}

reference: C# Get Computer's MAC address "OFFLINE"




回答2:


I think what you want would be some sort of licence key and an authorization method.

A quick google turned up this article which you may find useful.

http://www.codeproject.com/Articles/28678/Generating-Unique-Key-Finger-Print-for-a-Computer




回答3:


u can create the security constrain for exe like

  1. by Giving unique password
  2. By Entering the serial Key i.e. Licence Key which will know to u only or create random serial key generator based on the system.



回答4:


  1. get the MAC address of the computer that you want the .exe file to work on (in windows type: C:\getmac (see:https://helpdesk.latech.edu/index.php?option=com_content&task=view&id=207&Itemid=67 ).
  2. add the following c# code to your application ..... this code finds the computers MAC address each time it runs : C# Get Computer's MAC address "OFFLINE"
  3. in your c# code, check to see if the computers MAC address matches the 'allowed' MAC address.



回答5:


You can allow only one user run your program by using a hardware ID to identify the user using the application or you can use a licensing system.



来源:https://stackoverflow.com/questions/35914378/how-to-make-exe-file-work-on-one-computer-only

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!