2f9333d29a
- aggiunta gestione immagini (inizialmente solo recupero dimensioni in pixel).
179 lines
5.6 KiB
C++
179 lines
5.6 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : DllGraphics.cpp Data : 27.03.15 Versione : 1.6c9
|
|
// Contenuto : Funzioni di gestione della libreria opzionale EgtGraphics.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 27.03.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "DllGraphics.h"
|
|
#include "/EgtDev/Include/EGrDllMain.h"
|
|
#define NOMINMAX
|
|
#include <windows.h>
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Nome della libreria
|
|
#if defined( _WIN64) && defined( _DEBUG)
|
|
static const wchar_t* EGR_NAME = L"EgtGraphicsD64.dll" ;
|
|
#elif defined( _WIN64)
|
|
static const wchar_t* EGR_NAME = L"EgtGraphicsR64.dll" ;
|
|
#elif defined( _WIN32) && defined( _DEBUG)
|
|
static const wchar_t* EGR_NAME = L"EgtGraphicsD32.dll" ;
|
|
#else
|
|
static const wchar_t* EGR_NAME = L"EgtGraphicsR32.dll" ;
|
|
#endif
|
|
// Nome delle funzioni caricate
|
|
static const char* EGR_SETEGRLOGGER = "SetEGrLogger" ;
|
|
static const char* EGR_GETEGRVERSION = "GetEGrVersion" ;
|
|
static const char* EGR_SETEGRKEY = "SetEGrKey" ;
|
|
static const char* EGR_CREATEEGRSCENE = "CreateEGrScene" ;
|
|
static const char* EGR_CREATESCEEXECUTOR = "CreateSceExecutor" ;
|
|
static const char* EGR_CREATEEGRIMAGEMGR = "CreateEgrImageMgr" ;
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
HMODULE s_hEGr = nullptr ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
LoadGraphicsDll( ILogger* pLogger, const string& sKey)
|
|
{
|
|
// verifico la chiave
|
|
if ( ! TestKeyForEGr( sKey, 0, pLogger)) {
|
|
FreeGraphicsDll() ;
|
|
return false ;
|
|
}
|
|
// se già caricata
|
|
if ( s_hEGr != nullptr)
|
|
return true ;
|
|
// carico la libreria EgtGraphics
|
|
s_hEGr = LoadLibrary( EGR_NAME) ;
|
|
if ( s_hEGr == nullptr)
|
|
return false ;
|
|
// imposto logger
|
|
MySetEGrLogger( pLogger) ;
|
|
// imposto i codici della chiave
|
|
MySetEGrKey( sKey) ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
FreeGraphicsDll( void)
|
|
{
|
|
// se non è già caricata
|
|
if ( s_hEGr == nullptr)
|
|
return true ;
|
|
// libero la libreria EgtGraphics
|
|
FreeLibrary( s_hEGr) ;
|
|
s_hEGr = nullptr ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
IsLoadedGraphicsDll( void)
|
|
{
|
|
return ( s_hEGr != nullptr) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
MySetEGrLogger( ILogger* pLogger)
|
|
{
|
|
// verifico caricamento libreria EgtGraphics
|
|
if ( s_hEGr == nullptr)
|
|
return ;
|
|
// recupero funzione che imposta il logger
|
|
typedef void (* PF_SetEMkLogger) ( ILogger* pLogger) ;
|
|
PF_SetEMkLogger pFun = (PF_SetEMkLogger)GetProcAddress( s_hEGr, EGR_SETEGRLOGGER) ;
|
|
if ( pFun == nullptr)
|
|
return ;
|
|
pFun( pLogger) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
const char*
|
|
MyGetEGrVersion( void)
|
|
{
|
|
// verifico caricamento libreria EgtGraphics
|
|
if ( s_hEGr == nullptr)
|
|
return "" ;
|
|
// recupero funzione che restituisce la versione della libreria
|
|
typedef const char* (* PF_GetEGrVersion) ( void) ;
|
|
PF_GetEGrVersion pFun = (PF_GetEGrVersion)GetProcAddress( s_hEGr, EGR_GETEGRVERSION) ;
|
|
if ( pFun == nullptr)
|
|
return "" ;
|
|
return pFun() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
MySetEGrKey( const string& sKey)
|
|
{
|
|
// verifico caricamento libreria EgtGraphics
|
|
if ( s_hEGr == nullptr)
|
|
return ;
|
|
// recupero funzione che imposta i codici di protezione
|
|
typedef void (* PF_SetEGrKey) ( const string& sKey) ;
|
|
PF_SetEGrKey pFun = (PF_SetEGrKey)GetProcAddress( s_hEGr, EGR_SETEGRKEY) ;
|
|
if ( pFun == nullptr)
|
|
return ;
|
|
pFun( sKey) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
IEGrScene*
|
|
MyCreateEGrScene( void)
|
|
{
|
|
// verifico caricamento libreria EgtGraphics
|
|
if ( s_hEGr == nullptr)
|
|
return nullptr ;
|
|
// recupero funzione creazione oggetto
|
|
typedef IEGrScene* (* PF_CreateEGrScene) ( void) ;
|
|
PF_CreateEGrScene pFun = (PF_CreateEGrScene)GetProcAddress( s_hEGr, EGR_CREATEEGRSCENE) ;
|
|
if ( pFun == nullptr)
|
|
return nullptr ;
|
|
return pFun() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
ISceExecutor*
|
|
MyCreateSceExecutor( void)
|
|
{
|
|
// verifico caricamento libreria EgtGraphics
|
|
if ( s_hEGr == nullptr)
|
|
return nullptr ;
|
|
// recupero funzione creazione oggetto
|
|
typedef ISceExecutor* (* PF_CreateSceExecutor) ( void) ;
|
|
PF_CreateSceExecutor pFun = (PF_CreateSceExecutor)GetProcAddress( s_hEGr, EGR_CREATESCEEXECUTOR) ;
|
|
if ( pFun == nullptr)
|
|
return nullptr ;
|
|
return pFun() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
IEgrImageMgr*
|
|
MyCreateEgrImageMgr( void)
|
|
{
|
|
// verifico caricamento libreria EgtGraphics
|
|
if ( s_hEGr == nullptr)
|
|
return nullptr ;
|
|
// recupero funzione creazione oggetto
|
|
typedef IEgrImageMgr* (* PF_CreateEgrImageMgr) ( void) ;
|
|
PF_CreateEgrImageMgr pFun = (PF_CreateEgrImageMgr)GetProcAddress( s_hEGr, EGR_CREATEEGRIMAGEMGR) ;
|
|
if ( pFun == nullptr)
|
|
return nullptr ;
|
|
return pFun() ;
|
|
}
|