//---------------------------------------------------------------------------- // 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 EgtSetUserLevel( int nUserLev) { return ( ExeSetUserLevel( nUserLev) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetUserLevel( void) { return ExeGetUserLevel() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetKey( const wchar_t* wsKey) { return ( ExeSetKey( wstrztoA( wsKey)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetNestKey( const wchar_t* wsNestKey) { return ( ExeSetNestKey( wstrztoA( wsNestKey)) ? 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 EgtGetIniFile( wchar_t*& wsIniFile) { if ( &wsIniFile == nullptr) return FALSE ; // recupero il nome del file ini string sIniFile ; ExeGetIniFile( sIniFile) ; wsIniFile = _wcsdup( stringtoW( sIniFile)) ; return (( wsIniFile == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- 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 EgtSetNetHwKey( BOOL bNetHwKey) { return ( ExeSetNetHwKey( bNetHwKey != FALSE) ? 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 EgtGetKeyLeftDays( int* pnLeftDays) { if ( pnLeftDays == nullptr) return FALSE ; return ( ExeGetKeyLeftDays( *pnLeftDays) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetKeyOptLeftDays( int* pnOptLeftDays) { if ( pnOptLeftDays == nullptr) return FALSE ; return ( ExeGetKeyOptLeftDays( *pnOptLeftDays) ? 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) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetTempDir( const wchar_t* wsTempDir) { return ( ExeSetTempDir( wstrztoA( wsTempDir)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetTempDir( wchar_t*& wsTempDir) { string sTempDir ; if ( ! ExeGetTempDir( sTempDir)) return FALSE ; wsTempDir = _wcsdup( stringtoW( sTempDir)) ; return (( wsTempDir == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMainWindowHandle( HWND hMainWnd) { return ( ExeSetMainWindowHandle( hMainWnd) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetStringUtf8FromIni( const wchar_t* wsSec, const wchar_t* wsKey, const wchar_t* wsDef, wchar_t*& wsVal, const wchar_t* wsIniFile) { string sVal ; if ( ! ExeGetStringUtf8FromIni( wstrztoA( wsSec), wstrztoA( wsKey), wstrztoA( wsDef), sVal, wstrztoA( wsIniFile))) return FALSE ; wsVal = _wcsdup( stringtoW( sVal)) ; return (( wsVal == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtWriteStringUtf8ToIni( const wchar_t* wsSec, const wchar_t* wsKey, const wchar_t* wsVal, const wchar_t* wsIniFile) { return ( ExeWriteStringUtf8ToIni( wstrztoA( wsSec), wstrztoA( wsKey), wstrztoA( wsVal), wstrztoA( wsIniFile)) ? TRUE : FALSE) ; }