//---------------------------------------------------------------------------- // EgalTech 2014-2023 //---------------------------------------------------------------------------- // File : EGrDllMain.cpp Data : 30.05.23 Versione : 2.5e // Contenuto : Inizializzazione della DLL. // // // // Modifiche : 13.02.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DllMain.h" #include "/EgtDev/Include/EGrDllMain.h" #include "/EgtDev/Include/EGnGetModuleVer.h" #include "/EgtDev/Include/EGnGetKeyData.h" #include "/EgtDev/Include/EgtTrace.h" //--------------------------- Costanti ---------------------------------------- #if defined( _WIN64) && defined( _DEBUG) const char* EGR_STR = "EgtGraphicsD64.dll ver. " ; #elif defined( _WIN64) const char* EGR_STR = "EgtGraphicsR64.dll ver. " ; #elif defined( _WIN32) && defined( _DEBUG) const char* EGR_STR = "EgtGraphicsD32.dll ver. " ; #else const char* EGR_STR = "EgtGraphicsR32.dll ver. " ; #endif const int STR_DIM = 40 ; //----------------------------------------------------------------------------- static HINSTANCE s_hModule = NULL ; static char s_szEGrNameVer[STR_DIM] ; //----------------------------------------------------------------------------- BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) { if ( dwReason == DLL_PROCESS_ATTACH) { // Controllo commentato per problemi con VB.NET //#if defined( NDEBUG) // BOOL IsDbgPresent = FALSE ; // CheckRemoteDebuggerPresent( GetCurrentProcess(), &IsDbgPresent) ; // if ( IsDbgPresent) // return 0 ; //#endif s_hModule = hModule ; EGT_TRACE( "EgtGraphics.dll Initializing!\n") ; } else if ( dwReason == DLL_PROCESS_DETACH) { s_hModule = NULL ; EGT_TRACE( "EgtGraphics.dll Terminating!\n") ; } return 1 ; } //----------------------------------------------------------------------------- const char* GetEGrVersion( void) { std::string sVer ; GetModuleVersion( s_hModule, sVer) ; sprintf_s( s_szEGrNameVer, STR_DIM, "%s%s", EGR_STR, sVer.c_str()) ; return s_szEGrNameVer ; } //----------------------------------------------------------------------------- static ILogger* s_pLogger = nullptr ; //----------------------------------------------------------------------------- void SetEGrLogger( ILogger* pLogger) { s_pLogger = pLogger ; } //----------------------------------------------------------------------------- ILogger* GetEGrLogger( void) { return s_pLogger ; } //----------------------------------------------------------------------------- static std::string s_sKey ; static bool s_bNetHwKey = false ; //----------------------------------------------------------------------------- void SetEGrKey( const std::string& sKey) { s_sKey = sKey ; } //----------------------------------------------------------------------------- void SetEGrNetHwKey( bool bNetHwKey) { s_bNetHwKey = bNetHwKey ; } //----------------------------------------------------------------------------- const std::string& GetEGrKey( void) { return s_sKey ; } //----------------------------------------------------------------------------- bool GetEGrNetHwKey( void) { return s_bNetHwKey ; } //----------------------------------------------------------------------------- bool VerifyKey( int nKeyOpt) { // Controllo della licenza unsigned int nOpt1, nOpt2 ; int nOptExpDays ; int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; if ( ! GetEGrNetHwKey()) nRet = GetKeyOptions( GetEGrKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; if ( nRet != KEY_OK) { std::string sErr = "Error on Key (GRC/" + ToString( nRet) + ")" ; LOG_ERROR( GetEGrLogger(), sErr.c_str()) ; return false ; } if ( ( nOpt1 & KEYOPT_EGR_BASE) == 0 || ( nKeyOpt != 0 && ( nOpt1 & nKeyOpt) == 0) || nOptExpDays < GetCurrDay()) { std::string sErr = "Warning on Key (GRC/OPT)" ; LOG_ERROR( GetEGrLogger(), sErr.c_str()) ; return false ; } return true ; }