C# 如何使exe文件仅在一台计算机上工作
我用C#编写了一个程序,并用高级安装程序制作了exe文件,效果很好,但我想让这个exe文件在一台计算机上运行,因为有些客户C# 如何使exe文件仅在一台计算机上工作,c#,winforms,exe,C#,Winforms,Exe,我用C#编写了一个程序,并用高级安装程序制作了exe文件,效果很好,但我想让这个exe文件在一台计算机上运行,因为有些客户 获取exe并将此exe交给另一个用户,我想获得该权限并保护我的作品我想您需要的是某种许可证密钥和授权方法 谷歌很快找到了这篇文章,你可能会发现它很有用 u可以为类似exe的文件创建安全约束 通过提供唯一的密码 通过输入串行密钥,即仅向u知道或根据系统创建随机串行密钥生成器 在需要.exe的计算机上运行以下代码。要处理的文件(它将为您提供此机器的MAC地址)。 2.将此MAC
获取exe并将此exe交给另一个用户,我想获得该权限并保护我的作品我想您需要的是某种许可证密钥和授权方法 谷歌很快找到了这篇文章,你可能会发现它很有用
u可以为类似exe的文件创建安全约束
在需要.exe的计算机上运行以下代码。要处理的文件(它将为您提供此机器的MAC地址)。 2.将此MAC地址添加到下面的代码中 3.将下面的代码添加到您的C#代码中,以确保它仅在具有正确MAC地址(唯一)的计算机上运行
参考资料:通过使用硬件ID识别使用应用程序的用户,您只能允许一个用户运行您的程序,或者您可以使用许可证系统。我想这就是许可证发明的原因。这个问题有太多可能的答案,无法使用。让他们输入密码,检查某个硬件的MAC地址,使用某种第三方许可证系统,等等。我认为通过这种方式,每当我的程序在脱机时显示不同的MAC时,以及当它连接到不同的网络时,我都应该自己安装progame。知道为什么吗?
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;
}
}
}