EgtExecutor 2.1k6 :
- aggiunta gestione libreria di Nesting Automatico e relativa protezione - aggiunta funzione ExeSetLineAttribs per impostare spessore linee in grafica.
This commit is contained in:
+164
@@ -0,0 +1,164 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2019-2019
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DllNesting.cpp Data : 28.11.19 Versione : 2.1k6
|
||||
// Contenuto : Funzioni di gestione della libreria opzionale EgtNesting.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 28.11.19 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "DllNesting.h"
|
||||
#include "/EgtDev/Include/ENsDllMain.h"
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Nome della libreria
|
||||
#if defined( _WIN64) && defined( _DEBUG)
|
||||
static const wchar_t* ENS_NAME = L"EgtNestingD64.dll" ;
|
||||
#elif defined( _WIN64)
|
||||
static const wchar_t* ENS_NAME = L"EgtNestingR64.dll" ;
|
||||
#elif defined( _WIN32) && defined( _DEBUG)
|
||||
static const wchar_t* ENS_NAME = L"EgtNestingD32.dll" ;
|
||||
#else
|
||||
static const wchar_t* ENS_NAME = L"EgtNestingR32.dll" ;
|
||||
#endif
|
||||
// Nome delle funzioni caricate
|
||||
static const char* ENS_SETENSLOGGER = "SetENsLogger" ;
|
||||
static const char* ENS_GETENSVERSION = "GetENsVersion" ;
|
||||
static const char* ENS_SETENSKEY = "SetENsKey" ;
|
||||
static const char* ENS_SETENSKEY2 = "SetENsKey2" ;
|
||||
static const char* ENS_CREATEAUTONESTER = "CreateAutoNester" ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HMODULE s_hENs = nullptr ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
LoadNestingDll( ILogger* pLogger, const string& sKey, const string& sKey2)
|
||||
{
|
||||
// verifico la chiave
|
||||
if ( ! TestKeyForENs( sKey, 0, pLogger)) {
|
||||
FreeNestingDll() ;
|
||||
return false ;
|
||||
}
|
||||
// se già caricata
|
||||
if ( s_hENs != nullptr)
|
||||
return true ;
|
||||
// carico la libreria EgtNesting
|
||||
s_hENs = LoadLibrary( ENS_NAME) ;
|
||||
if ( s_hENs == nullptr)
|
||||
return false ;
|
||||
// imposto logger
|
||||
MySetENsLogger( pLogger) ;
|
||||
// imposto i codici della chiave
|
||||
MySetENsKey( sKey) ;
|
||||
// imposto i codici della seconda chiave
|
||||
MySetENsKey2( sKey2) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
FreeNestingDll( void)
|
||||
{
|
||||
// se non è già caricata
|
||||
if ( s_hENs == nullptr)
|
||||
return true ;
|
||||
// libero la libreria EgtNesting
|
||||
FreeLibrary( s_hENs) ;
|
||||
s_hENs = nullptr ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
IsLoadedNestingDll( void)
|
||||
{
|
||||
return ( s_hENs != nullptr) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MySetENsLogger( ILogger* pLogger)
|
||||
{
|
||||
// verifico caricamento libreria EgtNesting
|
||||
if ( s_hENs == nullptr)
|
||||
return ;
|
||||
// recupero funzione che imposta il logger
|
||||
typedef void (* PF_SetENsLogger) ( ILogger* pLogger) ;
|
||||
PF_SetENsLogger pFun = (PF_SetENsLogger)GetProcAddress( s_hENs, ENS_SETENSLOGGER) ;
|
||||
if ( pFun == nullptr)
|
||||
return ;
|
||||
pFun( pLogger) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const char*
|
||||
MyGetENsVersion( void)
|
||||
{
|
||||
// verifico caricamento libreria EgtNesting
|
||||
if ( s_hENs == nullptr)
|
||||
return "" ;
|
||||
// recupero funzione che restituisce la versione della libreria
|
||||
typedef const char* (* PF_GetEMkVersion) ( void) ;
|
||||
PF_GetEMkVersion pFun = (PF_GetEMkVersion)GetProcAddress( s_hENs, ENS_GETENSVERSION) ;
|
||||
if ( pFun == nullptr)
|
||||
return "" ;
|
||||
return pFun() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MySetENsKey( const string& sKey)
|
||||
{
|
||||
// verifico caricamento libreria EgtNesting
|
||||
if ( s_hENs == nullptr)
|
||||
return ;
|
||||
// recupero funzione che imposta i codici di protezione
|
||||
typedef void (* PF_SetENsKey) ( const string& sKey) ;
|
||||
PF_SetENsKey pFun = (PF_SetENsKey)GetProcAddress( s_hENs, ENS_SETENSKEY) ;
|
||||
if ( pFun == nullptr)
|
||||
return ;
|
||||
pFun( sKey) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
MySetENsKey2( const string& sKey2)
|
||||
{
|
||||
// verifico caricamento libreria EgtNesting
|
||||
if ( s_hENs == nullptr)
|
||||
return ;
|
||||
// recupero funzione che imposta i codici di protezione
|
||||
typedef void (* PF_SetENsKey2) ( const string& sKey2) ;
|
||||
PF_SetENsKey2 pFun = (PF_SetENsKey2)GetProcAddress( s_hENs, ENS_SETENSKEY2) ;
|
||||
if ( pFun == nullptr)
|
||||
return ;
|
||||
pFun( sKey2) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IAutoNester*
|
||||
MyCreateAutoNester( void)
|
||||
{
|
||||
// verifico caricamento libreria EgtNesting
|
||||
if ( s_hENs == nullptr)
|
||||
return nullptr ;
|
||||
// recupero funzione creazione oggetto
|
||||
typedef IAutoNester* (* PF_CreateAutoNester) ( void) ;
|
||||
PF_CreateAutoNester pFun = (PF_CreateAutoNester)GetProcAddress( s_hENs, ENS_CREATEAUTONESTER) ;
|
||||
if ( pFun == nullptr)
|
||||
return nullptr ;
|
||||
return pFun() ;
|
||||
}
|
||||
Reference in New Issue
Block a user