EgtInterface 1.6c9 :
- EgtGraphics, EgtExchange ed EgtMachKernel sono caricabili opzionalmente.
This commit is contained in:
+149
@@ -0,0 +1,149 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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 "DllGraphics.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" ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HMODULE s_hEGr = nullptr ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
LoadGraphicsDll( void)
|
||||
{
|
||||
// se già caricata
|
||||
if ( s_hEGr != nullptr)
|
||||
return true ;
|
||||
// carico la libreria EgtGraphics
|
||||
s_hEGr = LoadLibrary( EGR_NAME) ;
|
||||
return ( s_hEGr != nullptr) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
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 MachMgr
|
||||
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 MachMgr
|
||||
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 MachMgr
|
||||
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 MachMgr
|
||||
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 MachMgr
|
||||
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() ;
|
||||
}
|
||||
Reference in New Issue
Block a user