// 先检查程序中是否存在激活码
在ClientEncrypt
public static Boolean CheckLocalActivation()
{
try
{
Boolean ifExist = false;
String strPath = "./Activation.actia";
using (StreamReader sr = new StreamReader(strPath))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string strAuthorization = line;
String decryptCode = DecryptActivationCode(strAuthorization, PP_ACL, SV_ACL);
String strGetID = decryptCode.Substring(0, 17);
String strMacAddress = GetMacAddress();
if (strGetID == strMacAddress)
{
ifExist = true;
}
else
{
ifExist = false;
}
}
sr.Close();
}
return ifExist;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
//存在运行程序,不存在需要用户输入
//在Program.cs里的main方法中
if (ClientEncrypt.CheckLocalActivation())
{
Application.Run(main);
}
else
{
Application.Run(new InputActivation());
}