基本信息
源码名称:C#如何做软件授权(含使用文档)
源码大小:0.85M
文件格式:.rar
开发语言:C#
更新时间:2020-06-27
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
可直接发邮箱给我,我发给你
免费
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using My.License.Reg;
namespace My.License.Demo
{
public partial class Form1 : Form
{
public static int CheckRule = My.Framework.ConvertHelper.ToInt(My.Framework.Sys.SysConfig.GetAppSetting("CheckRule"));
public Form1()
{
InitializeComponent();
}
#region 授权处理
private bool isHasLicense = false;//是否已有许可证,默认为False
#region 是否有权限码且正确
/// <summary>
/// 是否有权限码且正确
/// </summary>
/// <returns></returns>
public bool IsHasCode(ref string errorMsg)
{
string error = string.Empty;
try
{
//2017-12-12 无软件系统及版本号授权
//isHasLicense = My.License.BizHelper.LicenseCheck.Instance.CheckLicense(ref errorMsg);
//2017-12-12 无软件系统及版本号授权
//2017-12-12 有软件系统及版本号授权
isHasLicense = My.License.BizHelper.LicenseCheck.Instance.CheckLicense(ref errorMsg, new SoftInfo());
//2017-12-12 有软件系统及版本号授权
}
catch (Exception ex)
{
error = ex.Message;
isHasLicense = false;
}
return isHasLicense;
}
#endregion
#region 获取相关License.xml文件
/// <summary>
/// 是否有权限码且正确
/// </summary>
/// <returns></returns>
public bool HasLicenseFile()
{
bool isHasLicenseXML = false;
string error = string.Empty;
try
{
string licenseXMLFilePath = My.Framework.FileHelper.GetApplicationPath() "\\License.xml";
string[] tempArry = licenseXMLFilePath.Split('\\');//MachineCode
int fileNameLength = tempArry[tempArry.Length - 1].Length;
string dir = licenseXMLFilePath.Substring(0, licenseXMLFilePath.Length - fileNameLength - 1);
if (Directory.Exists(dir))
{
if (File.Exists(licenseXMLFilePath))
{
//string licenseCheckStr = MyLicense.Interface.ComputerInfoHelper.GetLicenseCheckStr(MyLicense.Interface.ComputerInfoHelper.GetCheckKey(), MachineCode, string.Empty);
string licenseLscFilePath = My.Framework.FileHelper.GetApplicationPath() "\\" MachineCode ".lsc";
isHasLicenseXML = (File.Exists(licenseLscFilePath));
}
}
}
catch (Exception ex)
{
error = ex.Message;
isHasLicenseXML = false;
}
return isHasLicenseXML;
}
#endregion
#region 许可证已授权
/// <summary>
/// 许可证已授权
/// </summary>
public bool LicenseIsOK
{
get
{
return isHasLicense;
}
}
#endregion
#region 许可证已授权
/// <summary>
/// 许可证已授权
/// </summary>
public string MachineCode
{
get
{
return My.License.BizHelper.LicenseCheck.Instance.GetIMEI;//返回机器码串
}
}
#endregion
private void Form1_Load(object sender, EventArgs e)
{
string errorMsg = string.Empty;
if (IsHasCode(ref errorMsg) == false || HasLicenseFile() == false)
{
//this.Close();
//Application.Run(new LicenseImport());
this.Hide();
LicenseImport licenseFrm = new LicenseImport();
licenseFrm.Owner = this;
licenseFrm.ShowDialog();
}
else
{
string mgs = string.Empty;
MessageBox.Show("OK");
}
}
#endregion
}
}