Improve new MG license mechanism to make it work on Windows

This commit is contained in:
Christophe Bourcier 2023-04-27 11:09:49 +02:00
parent e1d1e96602
commit 2c178ca2ed

View File

@ -447,12 +447,10 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
return false; return false;
bool ok = false; bool ok = false;
// get the key from KeyGen typedef bool (*SignFun)(const std::string& );
std::string key = SMESHUtils_MGLicenseKeyGen::GetKey(error);
typedef int (*SignFun)(const char* );
// specific function to unlock each product // specific function to unlock each product
std::string function = "meshgems_" + product + "_unlock_product"; std::string function = "UnlockProduct";
SignFun signFun = (SignFun) GetProc( theLibraryHandle, function.c_str() ); SignFun signFun = (SignFun) GetProc( theLibraryHandle, function.c_str() );
if ( !signFun ) if ( !signFun )
@ -464,14 +462,13 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation
{ {
SMESH_TRY; SMESH_TRY;
int status = signFun( key.c_str() ); ok = signFun( product.c_str() );
// MeshGems status: 0: OK, 1: warning, -1: error
ok = status >= 0;
SMESH_CATCH( SMESH::returnError ); SMESH_CATCH( SMESH::returnError );
if ( !error.empty() ) if ( !error.empty() )
{ {
std::cerr << "error: " << error << std::endl;
ok = false; ok = false;
} }
else if ( !ok ) else if ( !ok )