Files
EgtGeneral/EGnDllMain.cpp
DarioS 24b02ba725 EgtGeneral 2.6f1 :
- aggiornamento riconoscimento OS per Windows 11
- modifiche per chiave di rete.
2023-06-05 08:08:06 +02:00

138 lines
3.8 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2023
//----------------------------------------------------------------------------
// File : EGnDllMain.cpp Data : 29.05.23 Versione : 2.5e3
// Contenuto : Inizializzazione della DLL.
//
//
//
// Modifiche : 20.11.13 DS Creazione modulo.
// 21.11.13 DS Agg. GetEGnVersion.
// 29.05.23 DS Agg. funzioni per chiave.
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "/EgtDev/Include/EGnDllMain.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* EGN_STR = "EgtGeneralD64.dll ver. " ;
#else
const char* EGN_STR = "EgtGeneralR64.dll ver. " ;
#endif
#elif defined( _WIN32)
#if defined( _DEBUG)
const char* EGN_STR = "EgtGeneralD32.dll ver. " ;
#else
const char* EGN_STR = "EgtGeneralR32.dll ver. " ;
#endif
#endif
const int STR_DIM = 40 ;
//-----------------------------------------------------------------------------
static HINSTANCE s_hModule = nullptr ;
static char s_szEGnNameVer[STR_DIM] ;
//-----------------------------------------------------------------------------
BOOL 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( "EgtGeneral.dll Initializing!\n") ;
}
else if ( dwReason == DLL_PROCESS_DETACH) {
s_hModule = nullptr ;
EGT_TRACE( "EgtGeneral.dll Terminating!\n") ;
}
return 1 ;
}
//-----------------------------------------------------------------------------
const char*
GetEGnVersion( void)
{
string sVer ;
GetModuleVersion( s_hModule, sVer) ;
sprintf_s( s_szEGnNameVer, STR_DIM, "%s%s", EGN_STR, sVer.c_str()) ;
return s_szEGnNameVer ;
}
//-----------------------------------------------------------------------------
static ILogger* s_pLogger = nullptr ;
//-----------------------------------------------------------------------------
void
SetEGnLogger( ILogger* pLogger)
{
s_pLogger = pLogger ;
}
//-----------------------------------------------------------------------------
ILogger*
GetEGnLogger( void)
{
return s_pLogger ;
}
//-----------------------------------------------------------------------------
static string s_sKey ;
static int s_nKeyType = KEY_LOCK_TYPE_ANY ;
static bool s_bNetHwKey = false ;
//-----------------------------------------------------------------------------
void
SetEGnKey( const string& sKey)
{
s_sKey = sKey ;
}
//-----------------------------------------------------------------------------
void
SetEGnKeyType( int nType)
{
s_nKeyType = nType ;
}
//-----------------------------------------------------------------------------
void
SetEGnNetHwKey( bool bNetHwKey)
{
s_bNetHwKey = bNetHwKey ;
}
//-----------------------------------------------------------------------------
const string&
GetEGnKey( void)
{
SetLockType( s_nKeyType) ;
return s_sKey ;
}
//-----------------------------------------------------------------------------
bool
GetEGnNetHwKey( void)
{
return s_bNetHwKey ;
}