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