//---------------------------------------------------------------------------- // EgalTech 2013-2014 //---------------------------------------------------------------------------- // File : KeyGenerator.cpp Data : 11.09.14 Versione : 1.5i2 // 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/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 string sKey = GetPrivateProfileStringUtf8( "General", "Key", "", m_pszProfileName) ; if ( VerifyKey( sKey, 1230, 16, 10) != KEY_OK) return FALSE ; // gestione linea di comando string sFileToOpen ; CCommandLineInfo cmdInfo ; ParseCommandLine( cmdInfo) ; if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen) sFileToOpen = WtoA( cmdInfo.m_strFileName) ; // Dialog interface CKeyGeneratorDlg dlg( sFileToOpen) ; m_pMainWnd = &dlg ; dlg.DoModal() ; // Per uscire dall'applicazione return FALSE ; } //---------------------------------------------------------------------------- string GetExeNameVer( void) { string sVer ; GetModuleVersion( NULL, sVer) ; return string( STR_EXE " ver." + sVer) ; }