简体   繁体   English

如何制作具有MAC地址限制的桌面应用程序的安装包?

[英]How to make installation package of a desktop application with MAC address restriction?

I have created an inventory system in c#. 我在c#中创建了一个清单系统。 Now I want to make its installation package so it can be installed on other computers. 现在,我要制作其安装包,以便可以将其安装在其他计算机上。

I know how to make an installation package but the problem is that I want to restrict the application from being installed on an other computer by checking the MAC address of the computer. 我知道如何制作安装软件包,但问题是我想通过检查计算机的MAC地址来限制将应用程序安装在另一台计算机上。 How can i check the MAC address of the computer during installation and compare it with the MAC address which I have given? 我如何在安装过程中检查计算机的MAC地址并将其与我提供的MAC地址进行比较?

Also I want to know that how can I integrate database with installation package so that I should not integrate it separately. 我也想知道如何将数据库与安装包集成在一起,这样就不必单独集成它。

You may use PhysicalAddress class ( http://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress%28v=vs.110%29.aspx ): 您可以使用PhysicalAddress类( http://msdn.microsoft.com/zh-cn/library/system.net.networkinformation.physicaladdress%28v=vs.110%29.aspx ):

NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            //for each j you can get the MAC
            PhysicalAddress address = nics[j].GetPhysicalAddress();
            byte[] bytes = address.GetAddressBytes();
            for (int i = 0; i < bytes.Length; i++)
            {
                // Display the physical address in hexadecimal.
                Console.Write("{0}", bytes[i].ToString("X2"));
                // Insert a hyphen after each byte, unless we are at the end of the
                // address.
                if (i != bytes.Length - 1)
                {
                    Console.Write("-");
                }
            }

You could store this value into DB and verify (when installing) if this MAC Address was already used. 您可以将该值存储到DB中,并在安装时验证(如果安装)了该MAC地址。

Be aware that is possible to clone MAC Address. 请注意,可以克隆MAC地址。 So, I would use another way to secure my application. 因此,我将使用另一种方式来保护我的应用程序。

***** UPDATE ***** *****更新*****

There are a lot of differents ways to reach machine uniqueness. 达到机器唯一性的方法有很多。 So I would start by hashing HDD info like this: http://www.vcskicks.com/hardware_id.php . 因此,我将从哈希HDD信息开始,例如: http : //www.vcskicks.com/hardware_id.php

ManagementObject dsk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + drive + @":""");
dsk.Get();
string volumeSerial = dsk["VolumeSerialNumber"].ToString();

You could also get more information together and generate a hash. 您还可以一起获取更多信息并生成哈希。 Here is an example: http://www.codeproject.com/Articles/28678/Generating-Unique-Key-Finger-Print-for-a-Computer 这是一个示例: http : //www.codeproject.com/Articles/28678/Generating-Uni​​que-Key-Finger-Print-for-a-Computer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM