diff --git a/KeyGenerator.cpp b/KeyGenerator.cpp index 5ab87c1..0f82202 100644 --- a/KeyGenerator.cpp +++ b/KeyGenerator.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2013-2014 +// EgalTech 2013-2020 //---------------------------------------------------------------------------- -// File : KeyGenerator.cpp Data : 11.09.14 Versione : 1.5i2 +// File : KeyGenerator.cpp Data : 26.12.20 Versione : 2.2l1 // Contenuto : Implementazione della classe applicazione generatore chiavi. // // @@ -25,7 +25,7 @@ using namespace std ; //---------------------------------------------------------------------------- #ifdef _DEBUG -#define new DEBUG_NEW + #define new DEBUG_NEW #endif //--------------------------- Define ----------------------------------------- @@ -85,7 +85,7 @@ CKeyGeneratorApp::InitInstance( void) // verifico la protezione SetLockType( KEY_LOCK_TYPE_HW) ; string sKey = GetPrivateProfileStringUtf8( "General", "Key", "", m_pszProfileName) ; - if ( VerifyKey( sKey, 823, 16, 10) != KEY_OK) { + if ( VerifyKey( sKey, 823, 2301, 10) != KEY_OK) { m_nExitCode = 1 ; return FALSE ; } diff --git a/KeyGenerator.rc b/KeyGenerator.rc index f99d3f0..0b79753 100644 Binary files a/KeyGenerator.rc and b/KeyGenerator.rc differ diff --git a/KeyGeneratorDlg.cpp b/KeyGeneratorDlg.cpp index bec3e68..42a98fc 100644 --- a/KeyGeneratorDlg.cpp +++ b/KeyGeneratorDlg.cpp @@ -27,9 +27,27 @@ using namespace std ; //---------------------------------------------------------------------------- #ifdef _DEBUG -#define new DEBUG_NEW + #define new DEBUG_NEW #endif +//---------------------------------------------------------------------------- +// Prodotti, versioni e sottoversioni +static const vector vsProd = { + "207", // librerie base + "823", // generatore di licenze + "1231", // vecchie librerie base + "3279", // EgtCAM5 + "5327", // SarmaxWall + "9423" // OmagCUT +} ; // altri valori : 463, 975, 1487, 2511, 3535, 4559, 5583 (max 9999 e deve contenere i bit di 207) +static const vector vsVer = { + "23", "22", "21", "19", "18", "16", "15" +} ; +static const vector vsSubVer = { + "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "" +} ; + + //---------------------------------------------------------------------------- // CAboutDlg dialog used for App About //---------------------------------------------------------------------------- @@ -157,6 +175,27 @@ CKeyGeneratorDlg::OnInitDialog( void) SetIcon( m_hIcon, TRUE) ; // Set big icon SetIcon( m_hIcon, FALSE) ; // Set small icon + // Assegno prodotti ammessi + CComboBox* pCbProd = (CComboBox*) GetDlgItem( IDC_PROD) ; + if ( pCbProd != nullptr) { + for ( auto& sProd : vsProd) + pCbProd->AddString( stringtoW( sProd)) ; + } + + // Assegno versioni ammesse + CComboBox* pCbVer = (CComboBox*) GetDlgItem( IDC_VER) ; + if ( pCbVer != nullptr) { + for ( auto& sVer : vsVer) + pCbVer->AddString( stringtoW( sVer)) ; + } + + // Assegno sottoversioni ammesse + CComboBox* pCbSub = (CComboBox*) GetDlgItem( IDC_SUBVER) ; + if ( pCbSub != nullptr) { + for ( auto& sSub : vsSubVer) + pCbSub->AddString( stringtoW( sSub)) ; + } + // eventuale apertura o esecuzione di file all'avvio if ( ! m_sFileToOpen.empty()) { // leggo il file e genero @@ -269,28 +308,28 @@ CKeyGeneratorDlg::LoadFile( const char* szFile) GetDlgItem( IDC_CUSTOMER)->SetWindowTextW( stringtoW( sCust)) ; string sLockId = GetPrivateProfileStringUtf8( sSec.c_str(), "LockId", "", szFile) ; GetDlgItem( IDC_MACHID)->SetWindowTextW( stringtoW( sLockId)) ; - int nProd = GetPrivateProfileInt( sSec.c_str(), "Product", 0, szFile) ; - int nSel = - 1 ; - switch ( nProd) { - case 207 : nSel = 0 ; break ; // librerie base - case 823 : nSel = 1 ; break ; // generatore di licenze - case 1231 : nSel = 2 ; break ; // vecchie librerie base - case 3279 : nSel = 3 ; break ; // EgtCAM5 - case 5327 : nSel = 4 ; break ; // SarmaxWall - case 9423 : nSel = 5 ; break ; // OmagCUT - } // altri valori : 463, 975, 1487, 2511, 3535, 4559, 5583 (max 9999 e deve contenere i bit di 207) - ((CComboBox*)GetDlgItem( IDC_PROD))->SetCurSel( nSel) ; - int nVer = GetPrivateProfileInt( sSec.c_str(), "Ver", 0, szFile) ; - nSel = - 1 ; - switch ( nVer) { - case 15 : nSel = 0 ; break ; - case 16 : nSel = 1 ; break ; - case 18 : nSel = 2 ; break ; - case 19 : nSel = 3 ; break ; - case 21 : nSel = 4 ; break ; - case 22 : nSel = 5 ; break ; + string sProd = GetPrivateProfileStringUtf8( sSec.c_str(), "Product", "", szFile) ; + int nProdSel = - 1 ; + for ( int i = 0 ; i < int( vsProd.size()) ; ++ i) { + if ( sProd == vsProd[i]) + nProdSel = i ; } - ((CComboBox*)GetDlgItem( IDC_VER))->SetCurSel( nSel) ; + ((CComboBox*)GetDlgItem( IDC_PROD))->SetCurSel( nProdSel) ; + string sVerSub = GetPrivateProfileStringUtf8( sSec.c_str(), "Ver", "", szFile) ; + string sVer = sVerSub.substr( 0, 2) ; + int nVerSel = - 1 ; + for ( int i = 0 ; i < int( vsVer.size()) ; ++ i) { + if ( sVer == vsVer[i]) + nVerSel = i ; + } + ((CComboBox*)GetDlgItem( IDC_VER))->SetCurSel( nVerSel) ; + string sSub = sVerSub.substr( 2, 2) ; + int nSubSel = - 1 ; + for ( int i = 0 ; i < int( vsSubVer.size()) ; ++ i) { + if ( sSub == vsSubVer[i]) + nSubSel = i ; + } + ((CComboBox*)GetDlgItem( IDC_SUBVER))->SetCurSel( nSubSel) ; int nLev = GetPrivateProfileInt( sSec.c_str(), "Lev", 0, szFile) ; ((CComboBox*)GetDlgItem( IDC_LEV))->SetCurSel( nLev - 1) ; int nExpTime = GetPrivateProfileInt( sSec.c_str(), "ExpDays", 0, szFile) ; @@ -351,11 +390,14 @@ CKeyGeneratorDlg::OnGenerate( void) // recupero la versione GetDlgItem( IDC_VER)->GetWindowTextW( wszTemp) ; string sVer = wstrztoA( wszTemp) ; - if ( ! mKey.SetVersion( sVer)) { + GetDlgItem( IDC_SUBVER)->GetWindowTextW( wszTemp) ; + string sSub = wstrztoA( wszTemp) ; + string sVerSub = sVer + sSub ; + if ( ! mKey.SetVersion( sVerSub)) { AfxMessageBox( L"Versione vuota o errata") ; return ; } - WritePrivateProfileStringUtf8( "Licence", "Ver", sVer.c_str(), AfxGetApp()->m_pszProfileName) ; + WritePrivateProfileStringUtf8( "Licence", "Ver", sVerSub.c_str(), AfxGetApp()->m_pszProfileName) ; // recupero il livello GetDlgItem( IDC_LEV)->GetWindowTextW( wszTemp) ; string sLev = wstrztoA( wszTemp) ; diff --git a/KeyMaker.cpp b/KeyMaker.cpp index c059e53..e2d59b1 100644 --- a/KeyMaker.cpp +++ b/KeyMaker.cpp @@ -103,7 +103,7 @@ KeyMaker::SetVersion( const std::string& sVer) { int nVer ; if ( ! FromString( sVer, nVer) || - nVer < 15 || nVer > 99) + nVer < 15 || nVer > 9999) return false ; m_nVer = nVer ; return true ; diff --git a/resource.h b/resource.h index 5de9e80..a42e15b 100644 Binary files a/resource.h and b/resource.h differ