//---------------------------------------------------------------------------- // EgalTech 2015-2020 //---------------------------------------------------------------------------- // File : DllExchange.cpp Data : 14.12.20 Versione : 2.2l2 // Contenuto : Funzioni di gestione della libreria opzionale EgtExchange. // // // // Modifiche : 27.03.15 DS Creazione modulo. // 03.07.18 DS Aggiunto ImportPnt. // 15.09.19 DS Aggiunto ExportSvg. // 14.12.20 DS Aggiunto ImportBtlx. // 23.10.23 DB Aggiunto Export3dm. // 07.11.23 DB Aggiunto Import3dm. // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "EXE.h" #include "DllExchange.h" #include "/EgtDev/Include/EExDllMain.h" #define NOMINMAX #include using namespace std ; //----------------------------------------------------------------------------- // Nome della libreria #if defined( _WIN64) && defined( _DEBUG) static const wchar_t* EEX_NAME = L"EgtExchangeD64.dll" ; #elif defined( _WIN64) static const wchar_t* EEX_NAME = L"EgtExchangeR64.dll" ; #elif defined( _WIN32) && defined( _DEBUG) static const wchar_t* EEX_NAME = L"EgtExchangeD32.dll" ; #else static const wchar_t* EEX_NAME = L"EgtExchangeR32.dll" ; #endif // Nome delle funzioni caricate static const char* EEX_SETEEXLOGGER = "SetEExLogger" ; static const char* EEX_GETEEXVERSION = "GetEExVersion" ; static const char* EEX_SETEEXKEY = "SetEExKey" ; static const char* EEX_SETEEXNETHWKEY = "SetEExNetHwKey" ; static const char* EEX_SETBTLAUXDIR = "SetBtlAuxDir" ; static const char* EEX_SETBTLLUADATA = "SetBtlLuaData" ; static const char* EEX_CREATEBEAMMGR = "CreateBeamMgr" ; static const char* EEX_CREATEIMPORTBTL = "CreateImportBtl" ; static const char* EEX_CREATEIMPORTBTLX = "CreateImportBtlx" ; static const char* EEX_CREATEIMPORTCNC = "CreateImportCnc" ; static const char* EEX_CREATEIMPORTCSF = "CreateImportCsf" ; static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ; static const char* EEX_CREATEIMPORTPNT = "CreateImportPnt" ; static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ; static const char* EEX_CREATEIMPORTOFF = "CreateImportOff" ; static const char* EEX_CREATEIMPORTPLY = "CreateImportPly" ; static const char* EEX_CREATEIMPORT3MF = "CreateImport3MF" ; static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ; static const char* EEX_CREATEEXPORTSTL = "CreateExportStl" ; static const char* EEX_CREATEEXPORT3MF = "CreateExport3MF" ; static const char* EEX_CREATEEXPORTSVG = "CreateExportSvg" ; static const char* EEX_SETTHREEJSLIBDIR = "SetThreeJSLibDir" ; static const char* EEX_CREATEEXPORTTHREEJS = "CreateExportThreeJS" ; static const char* EEX_CREATEEEXEXECUTOR = "CreateExcExecutor" ; //----------------------------------------------------------------------------- HMODULE s_hEEx = nullptr ; //----------------------------------------------------------------------------- bool LoadExchangeDll( ILogger* pLogger, const string& sKey, bool bNetHwKey) { // verifico la chiave if ( ! TestKeyForEEx( sKey, 0, pLogger)) { FreeExchangeDll() ; return false ; } // se già caricata if ( s_hEEx != nullptr) return true ; // carico la libreria EgtExchange s_hEEx = LoadLibrary( EEX_NAME) ; if ( s_hEEx == nullptr) return false ; // imposto logger MySetEExLogger( pLogger) ; // imposto i codici della chiave MySetEExKey( sKey) ; // imposto eventuale chiave di rete MySetEExNetHwKey( bNetHwKey) ; return true ; } //----------------------------------------------------------------------------- bool FreeExchangeDll( void) { // se non è già caricata if ( s_hEEx == nullptr) return true ; // libero la libreria EgtExchange FreeLibrary( s_hEEx) ; s_hEEx = nullptr ; return true ; } //----------------------------------------------------------------------------- bool IsLoadedExchangeDll( void) { return ( s_hEEx != nullptr) ; } //----------------------------------------------------------------------------- void MySetEExLogger( ILogger* pLogger) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return ; // recupero funzione che imposta il logger typedef void (* PF_SetEExLogger) ( ILogger* pLogger) ; PF_SetEExLogger pFun = (PF_SetEExLogger)GetProcAddress( s_hEEx, EEX_SETEEXLOGGER) ; if ( pFun == nullptr) return ; pFun( pLogger) ; } //----------------------------------------------------------------------------- const char* MyGetEExVersion( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return "" ; // recupero funzione che restituisce la versione della libreria typedef const char* (* PF_GetEExVersion) ( void) ; PF_GetEExVersion pFun = (PF_GetEExVersion)GetProcAddress( s_hEEx, EEX_GETEEXVERSION) ; if ( pFun == nullptr) return "" ; return pFun() ; } //----------------------------------------------------------------------------- void MySetEExKey( const string& sKey) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return ; // recupero funzione che imposta i codici di protezione typedef void (* PF_SetEExKey) ( const string& sKey) ; PF_SetEExKey pFun = (PF_SetEExKey)GetProcAddress( s_hEEx, EEX_SETEEXKEY) ; if ( pFun == nullptr) return ; pFun( sKey) ; } //----------------------------------------------------------------------------- void MySetEExNetHwKey( bool bNetHwKey) { // verifico caricamento libreria EgtGraphics if ( s_hEEx == nullptr) return ; // recupero funzione che imposta il flag per chiave di rete typedef void (* PF_SetEExNetHwKey) ( bool bNetHwKey) ; PF_SetEExNetHwKey pFun = (PF_SetEExNetHwKey)GetProcAddress( s_hEEx, EEX_SETEEXNETHWKEY) ; if ( pFun == nullptr) return ; pFun( bNetHwKey) ; } //----------------------------------------------------------------------------- bool MySetBtlAuxDir( const string& sBtlAuxDir) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return false ; // recupero funzione creazione oggetto typedef bool (* PF_SetBtlAuxDir) ( const string& sBtlAuxDir) ; PF_SetBtlAuxDir pFun = (PF_SetBtlAuxDir)GetProcAddress( s_hEEx, EEX_SETBTLAUXDIR) ; if ( pFun == nullptr) return false ; return pFun( sBtlAuxDir) ; } //----------------------------------------------------------------------------- bool MySetBtlLuaData( const string& sLuaLibsDir, const string& sLuaLastRequire) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return false ; // recupero funzione creazione oggetto typedef bool (* PF_SetBtlLuaData) ( const string& sLuaLibsDir, const string& sLuaLastRequire) ; PF_SetBtlLuaData pFun = (PF_SetBtlLuaData)GetProcAddress( s_hEEx, EEX_SETBTLLUADATA) ; if ( pFun == nullptr) return false ; return pFun( sLuaLibsDir, sLuaLastRequire) ; } //----------------------------------------------------------------------------- IBeamMgr* MyCreateBeamMgr( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IBeamMgr* (* PF_CreateBeamMgr) ( void) ; PF_CreateBeamMgr pFun = (PF_CreateBeamMgr)GetProcAddress( s_hEEx, EEX_CREATEBEAMMGR) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportBtl* MyCreateImportBtl( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportBtl* (* PF_CreateImportBtl) ( void) ; PF_CreateImportBtl pFun = (PF_CreateImportBtl)GetProcAddress( s_hEEx, EEX_CREATEIMPORTBTL) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportBtlx* MyCreateImportBtlx( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportBtlx* (* PF_CreateImportBtlx) ( void) ; PF_CreateImportBtlx pFun = (PF_CreateImportBtlx)GetProcAddress( s_hEEx, EEX_CREATEIMPORTBTLX) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportCnc* MyCreateImportCnc( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportCnc* (* PF_CreateImportCnc) ( void) ; PF_CreateImportCnc pFun = (PF_CreateImportCnc)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCNC) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportCsf* MyCreateImportCsf( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportCsf* (* PF_CreateImportCsf) ( void) ; PF_CreateImportCsf pFun = (PF_CreateImportCsf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCSF) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportDxf* MyCreateImportDxf( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportDxf* (* PF_CreateImportDxf) ( void) ; PF_CreateImportDxf pFun = (PF_CreateImportDxf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTDXF) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportPnt* MyCreateImportPnt( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportPnt* (* PF_CreateImportPnt) ( void) ; PF_CreateImportPnt pFun = (PF_CreateImportPnt)GetProcAddress( s_hEEx, EEX_CREATEIMPORTPNT) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportStl* MyCreateImportStl( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportStl* (* PF_CreateImportStl) ( void) ; PF_CreateImportStl pFun = (PF_CreateImportStl)GetProcAddress( s_hEEx, EEX_CREATEIMPORTSTL) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportOff* MyCreateImportOff( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportOff* (* PF_CreateImportOff) ( void) ; PF_CreateImportOff pFun = (PF_CreateImportOff)GetProcAddress( s_hEEx, EEX_CREATEIMPORTOFF) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImportPly* MyCreateImportPly( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImportPly* (* PF_CreateImportPly) ( void) ; PF_CreateImportPly pFun = (PF_CreateImportPly)GetProcAddress( s_hEEx, EEX_CREATEIMPORTPLY) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IImport3MF* MyCreateImport3MF( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IImport3MF* (* PF_CreateImport3MF) ( void) ; PF_CreateImport3MF pFun = (PF_CreateImport3MF)GetProcAddress( s_hEEx, EEX_CREATEIMPORT3MF) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IExportDxf* MyCreateExportDxf( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IExportDxf* (* PF_CreateExportDxf) ( void) ; PF_CreateExportDxf pFun = (PF_CreateExportDxf)GetProcAddress( s_hEEx, EEX_CREATEEXPORTDXF) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IExportStl* MyCreateExportStl( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IExportStl* (* PF_CreateExportStl) ( void) ; PF_CreateExportStl pFun = (PF_CreateExportStl)GetProcAddress( s_hEEx, EEX_CREATEEXPORTSTL) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IExport3MF* MyCreateExport3MF( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IExport3MF* (* PF_CreateExport3MF) ( void) ; PF_CreateExport3MF pFun = (PF_CreateExport3MF)GetProcAddress( s_hEEx, EEX_CREATEEXPORT3MF) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IExportSvg* MyCreateExportSvg( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IExportSvg* (* PF_CreateExportSvg) ( void) ; PF_CreateExportSvg pFun = (PF_CreateExportSvg)GetProcAddress( s_hEEx, EEX_CREATEEXPORTSVG) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- bool MySetThreeJSLibDir( const string& sThreeJSLibDir) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return false ; // recupero funzione creazione oggetto typedef bool ( *PF_SetThreeJSLibDir)( const string& sThreeJSLibDir) ; PF_SetThreeJSLibDir pFun = ( PF_SetThreeJSLibDir) GetProcAddress( s_hEEx, EEX_SETTHREEJSLIBDIR) ; if ( pFun == nullptr) return false ; return pFun( sThreeJSLibDir) ; } //----------------------------------------------------------------------------- IExportThreeJS* MyCreateExportThreeJS( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IExportThreeJS* (* PF_CreateExportThreeJS) ( void) ; PF_CreateExportThreeJS pFun = (PF_CreateExportThreeJS)GetProcAddress( s_hEEx, EEX_CREATEEXPORTTHREEJS) ; if ( pFun == nullptr) return nullptr ; return pFun() ; } //----------------------------------------------------------------------------- IExcExecutor* MyCreateExcExecutor( void) { // verifico caricamento libreria EgtExchange if ( s_hEEx == nullptr) return nullptr ; // recupero funzione creazione oggetto typedef IExcExecutor* (* PF_CreateExcExecutor) ( void) ; PF_CreateExcExecutor pFun = (PF_CreateExcExecutor)GetProcAddress( s_hEEx, EEX_CREATEEEXEXECUTOR) ; if ( pFun == nullptr) return nullptr ; return pFun() ; }