97 lines
5.1 KiB
C#
97 lines
5.1 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using XP.Common.License.Enums;
|
|
|
|
namespace XP.Common.License.Native
|
|
{
|
|
/// <summary>
|
|
/// CLMS SDK 原生方法封装 | CLMS SDK native methods encapsulation
|
|
/// </summary>
|
|
internal static class NativeMethods
|
|
{
|
|
/// <summary>
|
|
/// 登录验证 | Login verification
|
|
/// </summary>
|
|
/// <param name="str">验证字符串 | Verification string</param>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_Login", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern bool CLM_Login(StringBuilder str);
|
|
|
|
/// <summary>
|
|
/// 退出登录 | Logout
|
|
/// </summary>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_Logout", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static extern bool CLM_Logout();
|
|
|
|
/// <summary>
|
|
/// 检查许可范围 | Check license scope
|
|
/// </summary>
|
|
/// <returns>TRUE: 有许可 | TRUE: Has license; FALSE: 无许可 | FALSE: No license</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_Login_Scope", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static extern bool CLM_Login_Scope();
|
|
|
|
/// <summary>
|
|
/// 检查模块是否授权 | Check if module is licensed
|
|
/// </summary>
|
|
/// <param name="mod">模块ID | Module ID</param>
|
|
/// <param name="type">类型(暂无定义)| Type (undefined)</param>
|
|
/// <returns>TRUE: 模块可用 | TRUE: Module available; FALSE: 模块不可用 | FALSE: Module unavailable</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_ModuleIsLicensed", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static extern bool CLM_ModuleIsLicensed(ref ushort mod, ref ushort type);
|
|
|
|
/// <summary>
|
|
/// 获取保修到期日期 | Get warranty expiration date
|
|
/// </summary>
|
|
/// <param name="mon">月份 | Month</param>
|
|
/// <param name="day">日期 | Day</param>
|
|
/// <param name="year">年份 | Year</param>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_GetWarrantyExpiration", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static extern bool CLM_GetWarrantyExpiration(ref int mon, ref int day, ref int year);
|
|
|
|
/// <summary>
|
|
/// 获取浮动许可的IP地址和端口 | Get floating license IP and port
|
|
/// </summary>
|
|
/// <param name="ip">IP地址 | IP address</param>
|
|
/// <param name="port">端口 | Port</param>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_GetIP", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern bool CLM_GetIP(StringBuilder ip, StringBuilder port);
|
|
|
|
/// <summary>
|
|
/// 获取错误信息 | Get error message
|
|
/// </summary>
|
|
/// <param name="error">错误信息 | Error message</param>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_GetError", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern bool CLM_GetError(StringBuilder error);
|
|
|
|
/// <summary>
|
|
/// 检查系统时间 | Check system time
|
|
/// </summary>
|
|
/// <returns>TRUE: 系统时间正常 | TRUE: System time normal; FALSE: 系统时间异常 | FALSE: System time anomaly</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_CheckSystemTime", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static extern bool CLM_CheckSystemTime();
|
|
|
|
/// <summary>
|
|
/// 获取SmartService信息 | Get SmartService information
|
|
/// </summary>
|
|
/// <param name="ControllerId">控制器ID | Controller ID</param>
|
|
/// <param name="UserName">用户名 | User name</param>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_SmartService", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
internal static extern bool CLM_SmartService(StringBuilder ControllerId, StringBuilder UserName);
|
|
|
|
/// <summary>
|
|
/// 获取SMA日期 | Get SMA date
|
|
/// </summary>
|
|
/// <param name="mon">月份 | Month</param>
|
|
/// <param name="day">日期 | Day</param>
|
|
/// <param name="year">年份 | Year</param>
|
|
/// <returns>TRUE: 成功 | TRUE: Success; FALSE: 失败 | FALSE: Failure</returns>
|
|
[DllImport("MORCODE.dll", EntryPoint = "CLM_GetSmaDate", CallingConvention = CallingConvention.Cdecl)]
|
|
internal static extern bool CLM_GetSmaDate(ref int mon, ref int day, ref int year);
|
|
}
|
|
} |