diff --git a/KeyGenerator.cpp b/KeyGenerator.cpp index 1849975..ac27999 100644 --- a/KeyGenerator.cpp +++ b/KeyGenerator.cpp @@ -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, 1230, 16, 10) != KEY_OK) + if ( VerifyKey( sKey, 823, 16, 10) != KEY_OK) return FALSE ; // gestione linea di comando diff --git a/KeyGenerator.rc b/KeyGenerator.rc index 73e157c..34988d3 100644 Binary files a/KeyGenerator.rc and b/KeyGenerator.rc differ diff --git a/KeyGeneratorDlg.cpp b/KeyGeneratorDlg.cpp index 435fcf8..453c047 100644 --- a/KeyGeneratorDlg.cpp +++ b/KeyGeneratorDlg.cpp @@ -266,14 +266,22 @@ CKeyGeneratorDlg::LoadFile( const char* szFile) string sLockId = GetPrivateProfileStringUtf8( sSec.c_str(), "LockId", "", szFile) ; GetDlgItem( IDC_MACHID)->SetWindowTextW( stringtoW( sLockId)) ; int nProd = GetPrivateProfileInt( sSec.c_str(), "Product", 0, szFile) ; - ((CComboBox*)GetDlgItem( IDC_PROD))->SetCurSel( nProd - 1230) ; + int nSel = - 1 ; + switch ( nProd) { + case 823 : nSel = 0 ; break ; + case 1231 : nSel = 1 ; break ; + case 5327 : nSel = 2 ; break ; + case 9423 : nSel = 3 ; break ; + case 17615 : nSel = 4 ; break ; + } + ((CComboBox*)GetDlgItem( IDC_PROD))->SetCurSel( nSel) ; int nVer = GetPrivateProfileInt( sSec.c_str(), "Ver", 0, szFile) ; ((CComboBox*)GetDlgItem( IDC_VER))->SetCurSel( nVer - 15) ; 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) ; if ( nExpTime != 0) - ((CDateTimeCtrl*)GetDlgItem( IDC_EXPIRATION))->SetTime( &CTime( nExpTime * 24 * 3600)) ; + ((CDateTimeCtrl*)GetDlgItem( IDC_EXPIRATION))->SetTime( &CTime( unsigned( nExpTime) * 24 * 3600)) ; int nOpt1 = GetPrivateProfileInt( sSec.c_str(), "Opt1", 0, szFile) ; for ( int i = IDC_CHECK01, j = 0 ; i <= IDC_CHECK16 ; ++ i, ++ j) { if ( ( nOpt1 & ( 1 << j)) != 0) @@ -282,10 +290,16 @@ CKeyGeneratorDlg::LoadFile( const char* szFile) ((CButton*)GetDlgItem( i))->SetCheck( BST_UNCHECKED) ; } int nOpt2 = GetPrivateProfileInt( sSec.c_str(), "Opt2", 0, szFile) ; + for ( int i = IDC_CHECK2_01, j = 0 ; i <= IDC_CHECK2_16 ; ++ i, ++ j) { + if ( ( nOpt2 & ( 1 << j)) != 0) + ((CButton*)GetDlgItem( i))->SetCheck( BST_CHECKED) ; + else + ((CButton*)GetDlgItem( i))->SetCheck( BST_UNCHECKED) ; + } // check non ancora inseriti nel dialogo int nOptExpTime = GetPrivateProfileInt( sSec.c_str(), "OptExpDays", 0, szFile) ; if ( nOptExpTime != 0) - ((CDateTimeCtrl*)GetDlgItem( IDC_OPT_EXPIR))->SetTime( &CTime( nOptExpTime * 24 * 3600)) ; + ((CDateTimeCtrl*)GetDlgItem( IDC_OPT_EXPIR))->SetTime( &CTime( unsigned( nOptExpTime) * 24 * 3600)) ; return true ; } @@ -355,6 +369,10 @@ CKeyGeneratorDlg::OnGenerate( void) nOpt1 += ( 1 << j) ; } unsigned int nOpt2 = 0 ; + for ( int i = IDC_CHECK2_01, j = 0 ; i <= IDC_CHECK2_16 ; ++ i, ++ j) { + if ( ((CButton*)GetDlgItem( i))->GetCheck() == BST_CHECKED) + nOpt2 += ( 1 << j) ; + } if ( ! mKey.SetOptions( nOpt1, nOpt2)) { AfxMessageBox( L"Inserisci Opzioni valide") ; return ; @@ -375,7 +393,7 @@ CKeyGeneratorDlg::OnGenerate( void) WritePrivateProfileInt( "Licence", "OptExpDays", nOptDays, AfxGetApp()->m_pszProfileName) ; // verifico la protezione string sPKey = GetPrivateProfileStringUtf8( "General", "Key", "", AfxGetApp()->m_pszProfileName) ; - if ( VerifyKey( sPKey, 1230, 16, 10) != KEY_OK) + if ( VerifyKey( sPKey, 823, 16, 10) != KEY_OK) return ; // calcolo la chiave if ( ! mKey.CalcKey()) { diff --git a/resource.h b/resource.h index b7afe04..28c2631 100644 Binary files a/resource.h and b/resource.h differ