Files
EgtGeomKernel/EGkDllMain.cpp
T
Dario Sassi b1b1d6d434 EgtGeomKernel :
- adattamento per modifiche nei puntatori a funzione.
2025-10-13 08:46:09 +02:00

216 lines
5.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : EGkDllMain.cpp Data : 20.11.13 Versione : 1.3a1
// Contenuto : Inizializzazione della DLL.
//
//
//
// Modifiche : 16.11.13 DS Creazione modulo.
// 21.11.13 DS Agg. GetEGkVersion.
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "FontManager.h"
#include "\EgtDev\Include\EGkDllMain.h"
#include "\EgtDev\Include\EGnGetModuleVer.h"
#include "\EgtDev\Include\EgtTrace.h"
#include "\EgtDev\Include\SELkLockId.h"
using namespace std ;
//--------------------------- Costanti ----------------------------------------
#if defined( _WIN64)
#if defined( _DEBUG)
const char* EGK_STR = "EgtGeomKernelD64.dll ver. " ;
#else
const char* EGK_STR = "EgtGeomKernelR64.dll ver. " ;
#endif
#elif defined( _WIN32)
#if defined( _DEBUG)
const char* EGK_STR = "EgtGeomKernelD32.dll ver. " ;
#else
const char* EGK_STR = "EgtGeomKernelR32.dll ver. " ;
#endif
#endif
const int STR_DIM = 40 ;
//-----------------------------------------------------------------------------
static HINSTANCE s_hModule = nullptr ;
static char s_szEGkNameVer[STR_DIM] ;
//-----------------------------------------------------------------------------
extern "C" int 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( "EgtGeomKernel.dll Initializing!\n") ;
}
else if ( dwReason == DLL_PROCESS_DETACH) {
s_hModule = nullptr ;
EGT_TRACE( "EgtGeomKernel.dll Terminating!\n") ;
}
return 1 ;
}
//-----------------------------------------------------------------------------
const char*
GetEGkVersion( void)
{
string sVer ;
GetModuleVersion( s_hModule, sVer) ;
sprintf_s( s_szEGkNameVer, STR_DIM, "%s%s", EGK_STR, sVer.c_str()) ;
return s_szEGkNameVer ;
}
//-----------------------------------------------------------------------------
static int s_nDebugLev = 0 ;
//-----------------------------------------------------------------------------
void
SetEGkDebugLev( int nDebugLev)
{
s_nDebugLev = nDebugLev ;
}
//-----------------------------------------------------------------------------
int
GetEGkDebugLev( void)
{
return s_nDebugLev ;
}
//-----------------------------------------------------------------------------
static ILogger* s_pLogger = nullptr ;
//-----------------------------------------------------------------------------
void
SetEGkLogger( ILogger* pLogger)
{
s_pLogger = pLogger ;
}
//-----------------------------------------------------------------------------
ILogger*
GetEGkLogger( void)
{
return s_pLogger ;
}
//-----------------------------------------------------------------------------
static string s_sKey ;
static int s_nKeyType = KEY_LOCK_TYPE_ANY ;
static bool s_bNetHwKey = false ;
//-----------------------------------------------------------------------------
void
SetEGkKey( const string& sKey)
{
s_sKey = sKey ;
}
//-----------------------------------------------------------------------------
void
SetEGkKeyType( int nType)
{
s_nKeyType = nType ;
}
//-----------------------------------------------------------------------------
void
SetEGkNetHwKey( bool bNetHwKey)
{
s_bNetHwKey = bNetHwKey ;
}
//-----------------------------------------------------------------------------
const string&
GetEGkKey( void)
{
SetLockType( s_nKeyType) ;
return s_sKey ;
}
//-----------------------------------------------------------------------------
bool
GetEGkNetHwKey( void)
{
return s_bNetHwKey ;
}
//-----------------------------------------------------------------------------
void
InitFontManager( const string& sNfeFontDir, const string& sDefaultFont)
{
// recupero il font manager
FontManager& fntMgr = FontManager::GetFontManager() ;
// lo inizializzo
fntMgr.Init( sNfeFontDir, sDefaultFont) ;
}
//-----------------------------------------------------------------------------
void
SetDefaultFont( const string& sDefaultFont)
{
// recupero il font manager
FontManager& fntMgr = FontManager::GetFontManager() ;
// imposto il dato
fntMgr.SetDefaultFont( sDefaultFont) ;
}
//-----------------------------------------------------------------------------
const string&
GetNfeFontDir( void)
{
// recupero il font manager
FontManager& fntMgr = FontManager::GetFontManager() ;
// restituisco il dato
return fntMgr.GetNfeFontDir() ;
}
//-----------------------------------------------------------------------------
const string&
GetDefaultFont( void)
{
// recupero il font manager
FontManager& fntMgr = FontManager::GetFontManager() ;
// restituisco il dato
return fntMgr.GetDefaultFont() ;
}
//-----------------------------------------------------------------------------
static psfProcEvents s_pFunProcEvents = nullptr ;
//-----------------------------------------------------------------------------
bool
SetEGkProcessEvents( psfProcEvents pFun)
{
s_pFunProcEvents = pFun ;
return ( pFun != nullptr) ;
}
//-----------------------------------------------------------------------------
int
ProcessEvents( int nProg, int nPause)
{
if ( s_pFunProcEvents != nullptr)
return s_pFunProcEvents( nProg, nPause) ;
else
return 0 ;
}