//---------------------------------------------------------------------------- // EgalTech 2013-2023 //---------------------------------------------------------------------------- // File : KeyGenerator.cpp Data : 02.01.23 Versione : 2.5a1 // Contenuto : Implementazione della classe applicazione generatore chiavi. // // // // Modifiche : 11.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "KeyGenerator.h" #include "KeyGeneratorDlg.h" #include "/EgtDev/Include/EGnGetModuleVer.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtIniFile.h" #include "/EgtDev/Include/SELkLockId.h" #include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; //---------------------------------------------------------------------------- #ifdef _DEBUG #define new DEBUG_NEW #endif //--------------------------- Define ----------------------------------------- #if defined( NDEBUG) #define STR_EXE "KeyGeneratorR32.exe" #else #define STR_EXE "KeyGeneratorD32.exe" #endif //---------------------------------------------------------------------------- // The one and only CKeyGeneratorApp object CKeyGeneratorApp theApp ; //---------------------------------------------------------------------------- BEGIN_MESSAGE_MAP( CKeyGeneratorApp, CWinApp) ON_COMMAND( ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() //---------------------------------------------------------------------------- CKeyGeneratorApp::CKeyGeneratorApp( void) { } //---------------------------------------------------------------------------- BOOL CKeyGeneratorApp::InitInstance( void) { // CommonControls initialize INITCOMMONCONTROLSEX InitCtrls ; InitCtrls.dwSize = sizeof( InitCtrls) ; InitCtrls.dwICC = ICC_WIN95_CLASSES ; InitCommonControlsEx( &InitCtrls) ; CWinApp::InitInstance() ; AfxEnableControlContainer() ; // esco se debug nella versione release #if defined( NDEBUG) BOOL IsDbgPresent = FALSE ; CheckRemoteDebuggerPresent( GetCurrentProcess(), &IsDbgPresent) ; if ( IsDbgPresent) return FALSE ; #endif // recupero il direttorio del programma e lo imposto come corrente string sDir ; GetModuleDirectory( NULL, sDir) ; SetCurrentDirectory( stringtoW( sDir)) ; // costruisco path file INI string sFileIni= sDir + "\\KeyGenerator.ini" ; wchar_t* p = _wcsdup( stringtoW( sFileIni)) ; free( (void*) m_pszProfileName) ; m_pszProfileName = p ; // verifico la protezione SetLockType( KEY_LOCK_TYPE_HW) ; string sKey = GetPrivateProfileStringUtf8( "General", "Key", "", m_pszProfileName) ; if ( VerifyKey( sKey, 823, 2312, 10) != KEY_OK) { m_nExitCode = 1 ; return FALSE ; } // gestione linea di comando int nFlag = 0 ; string sFileToOpen = "" ; if ( __argc >= 2) sFileToOpen = WtoA( __wargv[1]) ; if ( __argc >= 3) FromString( LPSTR( WtoA( __wargv[2])), nFlag) ; // Dialog interface CKeyGeneratorDlg dlg( sFileToOpen, nFlag) ; m_pMainWnd = &dlg ; dlg.DoModal() ; // Per uscire dall'applicazione m_nExitCode = 0 ; return FALSE ; } //---------------------------------------------------------------------------- int CKeyGeneratorApp::ExitInstance( void) { CWinApp::ExitInstance() ; return m_nExitCode ; } //---------------------------------------------------------------------------- string GetExeNameVer( void) { string sVer ; GetModuleVersion( NULL, sVer) ; return string( STR_EXE " ver." + sVer) ; }