#0018 对中间件新增CLMS认证

This commit is contained in:
zhengxuan.zhang
2025-02-17 13:19:56 +08:00
parent 5b41557900
commit 12b139bbb1
9 changed files with 155 additions and 2 deletions
+130
View File
@@ -0,0 +1,130 @@
#include "stdafx.h"
#include "CLMS.h"
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
///////////////////////////////////////////////////////////////////////////////动态引用
HINSTANCE m_hCLM;
/// <summary>
/// 功能:使用MORCODE.DLL前验证使用软件是否正确,否则其他函数都不可正常调用
/// </summary>
/// <param name="_Massage">验证内容为软件指纹文件中字符串</param>
/// <returns>
/// TRUE :该软件可正常调用
/// FALSE :该软件不可正常调用
/// </returns>
typedef BOOL(WINAPI* CLM_Login)(char* _Massage);
CLM_Login m_pCLM_Login;
/// <summary>
/// 退出前执行一次,释放内存,记录使用信息
/// </summary>
/// <returns></returns>
typedef BOOL(WINAPI* CLM_Logout)();
CLM_Logout m_pCLM_Logout;
/// <summary>
/// 自动检查电脑中是否有当前软件的许可信息,过期/非本机电脑/其他软件 的许可证书都不会识别
/// </summary>
/// <returns>
/// TRUE :有该软件许可证书
/// FALSE :没有该软件许可证书
/// </returns>
typedef BOOL(WINAPI* CLM_Login_Scope)();
CLM_Login_Scope m_pCLM_Login_Scope;
/// <summary>
/// 输入模块ID验证模块可用性,输入CLMS服务器中模块ID -1(如服务器中模块ID为1,则mod参数输入0)
/// </summary>
/// <param name="_MOD">模块ID-1</param>
/// <param name="_OnLineType">暂无定义</param>
/// <returns>
/// TRUE :该模块可用
/// FALSE :该模块不可用
/// </returns>
typedef BOOL(WINAPI* CLM_ModuleIsLicensed)(UINT16& _MOD, UINT16& _OnLineType);
CLM_ModuleIsLicensed m_pCLM_ModuleIsLicensed;
/// <summary>
/// 获取到期日期
/// </summary>
/// <param name="_Month">月</param>
/// <param name="_Day">日</param>
/// <param name="_Year">年</param>
/// <returns></returns>
typedef BOOL(WINAPI* CLM_GetWarrantyExpiration)(int& _Month, int& _Day, int& _Year);
CLM_GetWarrantyExpiration m_pCLM_GetWarrantyExpiration;
/// <summary>
/// 输入模块ID获取该模块过期时间,输入CLMS服务器中模块ID -1(如服务器中模块ID为1,则mod参数输入0)
/// </summary>
/// <param name="_MOD">模块ID-1</param>
/// <param name="_Day">日</param>
/// <param name="_Month">月</param>
/// <param name="_Year">年</param>
/// <returns>
/// TRUE :时间有效
/// FALSE :该软件不可正常调用
/// </returns>
typedef BOOL(WINAPI* CLM_GetExpirationDateFor)(const int _MOD, int& _Day, int& _Month, int& _Year);
CLM_GetExpirationDateFor m_pCLM_GetExpirationDateFor;
BOOL CheckLicense()
{
m_hCLM = LoadLibrary(_T("CLMTool.dll"));
if (m_hCLM)
{
//Production
m_pCLM_Login = (CLM_Login)GetProcAddress(m_hCLM, "CLM_Login");
m_pCLM_Logout = (CLM_Logout)GetProcAddress(m_hCLM, "CLM_Logout");
m_pCLM_Login_Scope = (CLM_Login_Scope)GetProcAddress(m_hCLM, "CLM_Login_Scope");
m_pCLM_ModuleIsLicensed = (CLM_ModuleIsLicensed)GetProcAddress(m_hCLM, "CLM_ModuleIsLicensed");
m_pCLM_GetExpirationDateFor = (CLM_GetExpirationDateFor)GetProcAddress(m_hCLM, "CLM_GetExpirationDateFor");
m_pCLM_GetWarrantyExpiration = (CLM_GetWarrantyExpiration)GetProcAddress(m_hCLM, "CLM_GetWarrantyExpiration");
}
//////////////////////////////////////////////////////////////////1登陆验证
BOOL res = FALSE;
//Metus软件
char* strLogin = "rsWoGvmINesgabljzJZpTmMRGMLyKxFsaxpLRZSnpsujYlboLaKwSINrFbtddgMYgsXkCLwxfVUALwfQcxWEbvZZHjrrYwRkNCBMsjfxeKyannbTIVxsrQvLUWraoysNJFcYJrYnCSabWnxgezkDbvwHLksNqdWyvrfHqKeBLyyVyVYROgizPCqVaRQLkNrSROgvbAqShNZNuzKGHjOLYiwLaXnPKgvHcXuNeNLyuGMFeDnpiipTVDrvJaoNXDTq";
res = m_pCLM_Login(strLogin);
if (!res)
{
return res;
//登陆验证失败
}
//////////////////////////////////////////////////////////////////2检查许可
res = m_pCLM_Login_Scope();
if (!res)
{
return res;
//检查许可失败
}
//////////////////////////////////////////////////////////////////3获取许可模块
UINT16 Mod = 0;//
UINT16 OnLineType = 0;//许可状态
res = m_pCLM_ModuleIsLicensed(Mod, OnLineType);
if (!res)
{
return res;
//登陆验证失败
}
//////////////////////////////////////////////////////////////////4获取许可最早到期日期
int ModuleID = 2;
int Year, Month, Day;
res = m_pCLM_GetWarrantyExpiration(Month, Day, Year);//获取过期时间
if (!res)
{
return res;
//登陆验证失败
}
return res;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef CLMS_H_INCLUDED_
#define CLMS_H_INCLUDED_
BOOL CheckLicense();
#endif
@@ -99,6 +99,7 @@ copy "$(TargetDir)$(ProjectName).dll" "D:\HSI_Sevenocean_EF3.dll" </Command>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ACS\ACSC.h" />
<ClInclude Include="CLMS.h" />
<ClInclude Include="HSI.h" />
<ClInclude Include="SevenOcean\CMMIO_BASE.H" />
<ClInclude Include="logger.h" />
@@ -111,6 +112,7 @@ copy "$(TargetDir)$(ProjectName).dll" "D:\HSI_Sevenocean_EF3.dll" </Command>
<ClInclude Include="version.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CLMS.cpp" />
<ClCompile Include="SevenOcean\CMMIO_BASE.CPP" />
<ClCompile Include="SevenOcean\CMMIO_SERIAL.CPP" />
<ClCompile Include="logger.cpp" />
@@ -8,6 +8,7 @@
<ClCompile Include="HSI_Motion.cpp" />
<ClCompile Include="HSI_Sevenocean_EF3.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="CLMS.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="HSI.h" />
@@ -21,6 +22,7 @@
<ClInclude Include="version.h" />
<ClInclude Include="SevenOcean\CMMIO_SERIAL.H" />
<ClInclude Include="ACS\ACSC.h" />
<ClInclude Include="CLMS.h" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram1.cd" />
+13
View File
@@ -17,6 +17,7 @@
#include <iostream>
#include "windows.h"
#include "ACS/ACSC.h" //引入ACS运动控制卡头文件
#include "ClMS.h"
using namespace std;
#ifdef _DEBUG
@@ -244,6 +245,18 @@ HSI_Motion::HSI_Motion()
g_pLogger->SendAndFlushWithTime(L"\n");
g_pLogger->SendAndFlushWithTime(L"==========================================================\n");
// CLMS 授权验证
if (!CheckLicense())
{
wprintf(L"Can't find license\n");
//弹窗提示
AfxMessageBox(_T("acs metus middleware No authorization found, please contact the corresponding sales"), MB_ICONWARNING | MB_OK);
g_pLogger->SendAndFlushWithTime(L"Acs Middleware No authorization found, Please contact the corresponding sales\n");
}
g_pLogger->SendAndFlushWithTime(L"Acs Middleware Check License OK\n");
//档位参数
for (int i = 0; i < 5; i++)
{
+2 -2
View File
@@ -12,5 +12,5 @@
#define HSI_VERSION_REVNUM
#define HSI_VERSION_BUILD_DATE _T(__DATE__ )
#define HSI_VERSION_BUILD_TIME _T(__TIME__ )
#define HSI_FILE_DESCRIPTION "2025.02.13 / 17:57 "
#define HSI_FILE_CSDESCRIPTION _T("2025.02.13 / 17:57 ")
#define HSI_FILE_DESCRIPTION "2025.02.17 / 11:10 "
#define HSI_FILE_CSDESCRIPTION _T("2025.02.17 / 11:10 ")
Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B