From e6ea9b2ccd911604d848daf65bcbf66d65833929 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 7 Mar 2019 07:53:09 +0000 Subject: [PATCH] KeyGenerator 2.1c2 : - nel caso di calcolo diretto della licenza il nome del file di licenza coincide con quello del file dati e non si incrementa il conto. --- KeyGenerator.rc | Bin 28448 -> 28448 bytes KeyGeneratorDlg.cpp | 10 +++++----- KeyGeneratorDlg.h | 2 +- KeyMaker.cpp | 7 ++++--- KeyMaker.h | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/KeyGenerator.rc b/KeyGenerator.rc index df972df4c7404afbc1e5ea3e99a4b9b907f69292..847f315b35f312193946264f87d128602677a2fe 100644 GIT binary patch delta 54 zcmZ2*k8#00#tl5Cj7FPzO>LPOjVALu=x(0ikifY4hNS_J4-|gQH2I5t9$adI9su;l B5LPO4JY$E=x(0ikifY4hNS_J4-|gQH2I5t9$adI9su-K B5LoadIcon( IDR_MAINFRAME) ; // eventuale file da caricare all'avvio m_sFileToOpen = sFileToOpen ; - m_nFlag = nFlag ; + m_bSpecial = ( ! m_sFileToOpen.empty() && nFlag == 1) ; } //---------------------------------------------------------------------------- @@ -161,7 +161,7 @@ CKeyGeneratorDlg::OnInitDialog( void) if ( ! m_sFileToOpen.empty()) { // leggo il file e genero if ( LoadFile( m_sFileToOpen.c_str())) { - if ( m_nFlag == 1) + if ( m_bSpecial) PostMessage( WM_COMMAND, IDC_GENER, 0) ; return TRUE ; } @@ -417,14 +417,14 @@ CKeyGeneratorDlg::OnGenerate( void) mKey.GetKey( sKey) ; // salvo i dati - if ( ! mKey.SaveData()) + if ( ! mKey.SaveData( m_bSpecial)) AfxMessageBox( L"Errore nel salvataggio dei dati") ; // visualizzo i risultanti CKeyDlg dlgKey( sKey) ; dlgKey.DoModal() ; - // se lanciato con file, esco dal programma - if ( ! m_sFileToOpen.empty() && m_nFlag == 1) + // se lanciato con file e flag 1, esco dal programma + if ( m_bSpecial) PostMessage( WM_CLOSE, 0, 0) ; } diff --git a/KeyGeneratorDlg.h b/KeyGeneratorDlg.h index 88c2775..4730263 100644 --- a/KeyGeneratorDlg.h +++ b/KeyGeneratorDlg.h @@ -39,7 +39,7 @@ class CKeyGeneratorDlg : public CDialogEx private : HICON m_hIcon ; std::string m_sFileToOpen ; - int m_nFlag ; + bool m_bSpecial ; DECLARE_MESSAGE_MAP() } ; diff --git a/KeyMaker.cpp b/KeyMaker.cpp index d0c8490..c059e53 100644 --- a/KeyMaker.cpp +++ b/KeyMaker.cpp @@ -175,7 +175,7 @@ KeyMaker::GetKey( string& sKey) //---------------------------------------------------------------------------- bool -KeyMaker::SaveData( void) +KeyMaker::SaveData( bool bSpecial) { // direttorio di salvataggio string sDataDir = GetPrivateProfileStringUtf8( "General", "DataDir", "C:/EgtProg/KeyGenerator", AfxGetApp()->m_pszProfileName) ; @@ -190,7 +190,8 @@ KeyMaker::SaveData( void) // se cambiati i dati, aggiungo nuova versione di licenza if ( DiffLicence( sLogFile.c_str())) { // salvo nuovo indice salvataggio - ++ nLast ; + if ( ! bSpecial) + ++ nLast ; WritePrivateProfileInt( "Index", "Last", nLast, sLogFile.c_str()) ; // aggiorno nome sezione sSec = "Licence" + ToString( nLast) ; @@ -200,7 +201,7 @@ KeyMaker::SaveData( void) } // path file licenza - string sLicFile = sDataDir + "\\" + m_sCustomer + "_" + sSec + ".lic" ; + string sLicFile = sDataDir + "\\" + m_sCustomer + ( bSpecial ? "" : "_" + sSec) + ".lic" ; // linea per evitare problemi con BOM ofstream ofOut( stringtoW( sLicFile), ios_base::out | ios_base::trunc) ; if ( ! ofOut.good()) diff --git a/KeyMaker.h b/KeyMaker.h index fc56326..5b36632 100644 --- a/KeyMaker.h +++ b/KeyMaker.h @@ -31,7 +31,7 @@ class KeyMaker bool SetOptExpirDays( int nOptExpDays) ; bool CalcKey( void) ; bool GetKey( std::string& sKey) ; - bool SaveData( void) ; + bool SaveData( bool bSpecial) ; private : bool DiffLicence( const char* szFile) ;