8a232b60b9
- aggiunta interfaccia per EgtSetIniFile.
253 lines
7.5 KiB
C++
253 lines
7.5 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : API_General.cpp Data : 01.09.14 Versione : 1.5i1
|
|
// Contenuto : Funzioni generali per API.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 01.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "API.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EInDllMain.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EgtStringConverter.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtInit( int nDebug, const wchar_t* wsLogFile, const wchar_t* wsLogMsg)
|
|
{
|
|
string sLogMsg = wstrztoA( wsLogMsg) ;
|
|
sLogMsg += "\n" ;
|
|
sLogMsg += GetEInVersion() ;
|
|
return ( ExeInit( nDebug, wstrztoA( wsLogFile), sLogMsg) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtExit( void)
|
|
{
|
|
return ( ExeExit() ? TRUE : FALSE) ;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetKey( const wchar_t* wsKey)
|
|
{
|
|
return ( ExeSetKey( wstrztoA( wsKey)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetFont( const wchar_t* wsNfeFontDir, const wchar_t* wsDefaultFont)
|
|
{
|
|
return ( ExeSetFont( wstrztoA( wsNfeFontDir), wstrztoA( wsDefaultFont)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetNfeFontDir( wchar_t*& wsNfeFontDir)
|
|
{
|
|
if ( &wsNfeFontDir == nullptr)
|
|
return FALSE ;
|
|
// recupero il nome del direttorio dei font Nfe
|
|
string sNfeFontDir ;
|
|
ExeGetNfeFontDir( sNfeFontDir) ;
|
|
wsNfeFontDir = _wcsdup( stringtoW( sNfeFontDir)) ;
|
|
return (( wsNfeFontDir == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetDefaultFont( wchar_t*& wsDefaultFont)
|
|
{
|
|
if ( &wsDefaultFont == nullptr)
|
|
return FALSE ;
|
|
// recupero il nome del font di default
|
|
string sDefaultFont ;
|
|
ExeGetDefaultFont( sDefaultFont) ;
|
|
wsDefaultFont = _wcsdup( stringtoW( sDefaultFont)) ;
|
|
return (( wsDefaultFont == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetLuaLibs( const wchar_t* wsLuaLibsDir)
|
|
{
|
|
return ( ExeSetLuaLibs( wstrztoA( wsLuaLibsDir)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetIniFile( const wchar_t* wsIniFile)
|
|
{
|
|
return ( ExeSetIniFile( wstrztoA( wsIniFile)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetCommandLogger( const wchar_t* wsLogFile)
|
|
{
|
|
return ( ExeSetCommandLogger( wstrztoA( wsLogFile)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
__stdcall EgtEnableCommandLogger( void)
|
|
{
|
|
ExeEnableCommandLogger() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
__stdcall EgtDisableCommandLogger( void)
|
|
{
|
|
ExeDisableCommandLogger() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetVersionInfo( wchar_t*& wsVer)
|
|
{
|
|
// recupero le informazioni sulle DLL
|
|
string sVer ;
|
|
sVer = GetEInVersion() ;
|
|
sVer += "\r\n" ;
|
|
if ( ! ExeGetVersionInfo( sVer, "\r\n"))
|
|
return FALSE ;
|
|
wsVer = _wcsdup( stringtoW( sVer)) ;
|
|
return (( wsVer == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetKeyInfo( wchar_t*& wsKey)
|
|
{
|
|
// recupero le informazioni sulla protezione
|
|
string sKey ;
|
|
if ( ! ExeGetKeyInfo( sKey))
|
|
return FALSE ;
|
|
wsKey = _wcsdup( stringtoW( sKey)) ;
|
|
return (( wsKey == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetLockType( int nType)
|
|
{
|
|
return ( ExeSetLockType( nType) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetKeyLevel( int nProd, int nVer, int nLev, int* pnKLev)
|
|
{
|
|
if ( pnKLev == nullptr)
|
|
return FALSE ;
|
|
return ( ExeGetKeyLevel( nProd, nVer, nLev, *pnKLev) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetKeyOptions( int nProd, int nVer, int nLev, unsigned int* pnOpt2)
|
|
{
|
|
if ( pnOpt2 == nullptr)
|
|
return FALSE ;
|
|
return ( ExeGetKeyOptions( nProd, nVer, nLev, *pnOpt2) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetOsInfo( wchar_t*& wsOs)
|
|
{
|
|
// recupero le informazioni sul sistema operativo
|
|
string sOs ;
|
|
if ( ! ExeGetOsInfo( sOs))
|
|
return FALSE ;
|
|
wsOs = _wcsdup( stringtoW( sOs)) ;
|
|
return (( wsOs == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetCpuInfo( wchar_t*& wsCpu)
|
|
{
|
|
// recupero le informazioni sulla Cpu
|
|
string sCpu ;
|
|
if ( ! ExeGetCpuInfo( sCpu))
|
|
return FALSE ;
|
|
wsCpu = _wcsdup( stringtoW( sCpu)) ;
|
|
return (( wsCpu == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetMemoryInfo( wchar_t*& wsMem)
|
|
{
|
|
// recupero le informazioni sulla memoria presente
|
|
string sMem ;
|
|
if ( ! ExeGetMemoryInfo( sMem))
|
|
return FALSE ;
|
|
wsMem = _wcsdup( stringtoW( sMem)) ;
|
|
return (( wsMem == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtFreeMemory( void* pMem)
|
|
{
|
|
if ( pMem == nullptr)
|
|
return FALSE ;
|
|
free( pMem) ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtOutLog( const wchar_t* wsMsg)
|
|
{
|
|
return ( ExeOutLog( wstrztoA( wsMsg)) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetProcessEvents( pfProcEvents pFun)
|
|
{
|
|
return ( ExeSetProcessEvents( pFun) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
static pfOutTextW s_pFunOutText = nullptr ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
__stdcall MyOutText( const string& sText)
|
|
{
|
|
if ( s_pFunOutText == nullptr)
|
|
return false ;
|
|
wchar_t* wsText = _wcsdup( stringtoW( sText)) ;
|
|
if ( wsText == nullptr)
|
|
return false ;
|
|
BOOL bOk = s_pFunOutText( wsText) ;
|
|
free( wsText) ;
|
|
return ( bOk != FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetOutText( pfOutTextW pFun)
|
|
{
|
|
s_pFunOutText = pFun ;
|
|
return ( ExeSetOutText( (( pFun != nullptr) ? MyOutText : nullptr)) ? TRUE : FALSE) ;
|
|
}
|