KeyGenerator 1.5i2 :

- primo rilascio.
This commit is contained in:
Dario Sassi
2014-09-13 21:32:52 +00:00
parent 52da3b62e2
commit 94640720eb
16 changed files with 1048 additions and 0 deletions
+105
View File
@@ -0,0 +1,105 @@
//----------------------------------------------------------------------------
// 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/EGnStringConverter.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, 15, 01) != KEY_OK)
return FALSE ;
// Dialog interface
CKeyGeneratorDlg dlg ;
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) ;
}
+36
View File
@@ -0,0 +1,36 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : KeyGenerator.h Data : 11.09.14 Versione : 1.5i2
// Contenuto : Dichiarazione della classe applicazione generatore chiavi.
//
//
//
// Modifiche : 11.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include <string>
//----------------------------------------------------------------------------
class CKeyGeneratorApp : public CWinApp
{
public :
CKeyGeneratorApp( void) ;
public :
virtual BOOL InitInstance( void) ;
DECLARE_MESSAGE_MAP()
} ;
//----------------------------------------------------------------------------
std::string GetExeNameVer( void) ;
BIN
View File
Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyGenerator", "KeyGenerator.vcxproj", "{0516D641-6731-48BE-AC94-C9E957D371B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0516D641-6731-48BE-AC94-C9E957D371B6}.Debug|Win32.ActiveCfg = Debug|Win32
{0516D641-6731-48BE-AC94-C9E957D371B6}.Debug|Win32.Build.0 = Debug|Win32
{0516D641-6731-48BE-AC94-C9E957D371B6}.Release|Win32.ActiveCfg = Release|Win32
{0516D641-6731-48BE-AC94-C9E957D371B6}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+142
View File
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{0516D641-6731-48BE-AC94-C9E957D371B6}</ProjectGuid>
<RootNamespace>KeyGenerator</RootNamespace>
<Keyword>MFCProj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)D$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>copy $(TargetPath) \EgtProg\KeyGenerator\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>copy $(TargetPath) \EgtProg\KeyGenerator\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="res\KeyGenerator.ico" />
<None Include="res\KeyGenerator.rc2" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="KeyGenerator.h" />
<ClInclude Include="KeyGeneratorDlg.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="KeyGenerator.cpp" />
<ClCompile Include="KeyGeneratorDlg.cpp" />
<ClCompile Include="KeyMaker.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="KeyGenerator.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="KeyGenerator.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
+61
View File
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="File di origine">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="File di intestazione">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="File di risorse">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="res\KeyGenerator.rc2">
<Filter>File di risorse</Filter>
</None>
<None Include="res\KeyGenerator.ico">
<Filter>File di risorse</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="KeyGenerator.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="KeyGeneratorDlg.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="KeyGenerator.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="KeyGeneratorDlg.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="KeyMaker.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="KeyGenerator.rc">
<Filter>File di risorse</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
+333
View File
@@ -0,0 +1,333 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : KeyGeneratorDlg.cpp Data : 11.09.14 Versione : 1.5i2
// Contenuto : Implementazione della classe dialogo generatore chiavi.
//
//
//
// Modifiche : 11.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "afxdialogex.h"
#include "resource.h"
#include "KeyGenerator.h"
#include "KeyGeneratorDlg.h"
#include "KeyMaker.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EgtIniFile.h"
using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//----------------------------------------------------------------------------
// CAboutDlg dialog used for App About
//----------------------------------------------------------------------------
class CAboutDlg : public CDialogEx
{
public :
CAboutDlg( void) ;
protected :
BOOL OnInitDialog( void) ;
DECLARE_MESSAGE_MAP()
} ;
//----------------------------------------------------------------------------
CAboutDlg::CAboutDlg( void)
: CDialogEx( IDD_ABOUTBOX)
{
}
//----------------------------------------------------------------------------
BOOL
CAboutDlg::OnInitDialog( void)
{
CDialog::OnInitDialog() ;
GetDlgItem( IDC_EXEVER)->SetWindowText( stringtoW( GetExeNameVer())) ;
return TRUE ;
}
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
// CKeyDlg dialog used for Key visualization
//----------------------------------------------------------------------------
class CKeyDlg : public CDialogEx
{
public :
CKeyDlg( const string& sKey) ;
protected :
BOOL OnInitDialog( void) ;
private :
string m_sKey ;
DECLARE_MESSAGE_MAP()
} ;
//----------------------------------------------------------------------------
CKeyDlg::CKeyDlg( const string& sKey)
: CDialogEx( IDD_KEYBOX)
{
m_sKey = sKey ;
}
//----------------------------------------------------------------------------
BOOL
CKeyDlg::OnInitDialog( void)
{
CDialog::OnInitDialog() ;
GetDlgItem( IDC_KEY)->SetWindowText( stringtoW( m_sKey)) ;
return TRUE ;
}
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CKeyDlg, CDialogEx)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
// CKeyGeneratorDlg dialog
//----------------------------------------------------------------------------
CKeyGeneratorDlg::CKeyGeneratorDlg( CWnd* pParent)
: CDialogEx( IDD_KEYGENERATOR_DIALOG)
{
m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME) ;
}
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CKeyGeneratorDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED( ID_GENER, OnGenerate)
ON_WM_CLOSE()
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
BOOL
CKeyGeneratorDlg::OnInitDialog( void)
{
CDialogEx::OnInitDialog() ;
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if ( pSysMenu != NULL) {
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if ( ! strAboutMenu.IsEmpty()) {
pSysMenu->AppendMenu( MF_SEPARATOR) ;
pSysMenu->AppendMenu( MF_STRING, IDM_ABOUTBOX, strAboutMenu) ;
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon( m_hIcon, TRUE) ; // Set big icon
SetIcon( m_hIcon, FALSE) ; // Set small icon
// Assegno ultimi valori inseriti
string sCust = GetPrivateProfileStringUtf8( "Data", "Customer", "", AfxGetApp()->m_pszProfileName) ;
GetDlgItem( IDC_CUSTOMER)->SetWindowTextW( stringtoW( sCust)) ;
string sMachId = GetPrivateProfileStringUtf8( "Data", "MachineId", "", AfxGetApp()->m_pszProfileName) ;
GetDlgItem( IDC_MACHID)->SetWindowTextW( stringtoW( sMachId)) ;
int nSelProd = GetPrivateProfileInt( "Data", "SelProduct", 0, AfxGetApp()->m_pszProfileName) ;
((CComboBox*)GetDlgItem( IDC_PROD))->SetCurSel( nSelProd) ;
int nSelVer = GetPrivateProfileInt( "Data", "SelVer", 0, AfxGetApp()->m_pszProfileName) ;
((CComboBox*)GetDlgItem( IDC_VER))->SetCurSel( nSelVer) ;
int nSelLev = GetPrivateProfileInt( "Data", "SelLev", 0, AfxGetApp()->m_pszProfileName) ;
((CComboBox*)GetDlgItem( IDC_LEV))->SetCurSel( nSelLev) ;
int nExpTime = GetPrivateProfileInt( "Data", "ExpTime", 0, AfxGetApp()->m_pszProfileName) ;
if ( nExpTime != 0)
((CDateTimeCtrl*)GetDlgItem( IDC_EXPIRATION))->SetTime( &CTime( nExpTime)) ;
return TRUE ; // return TRUE unless you set the focus to a control
}
//----------------------------------------------------------------------------
void
CKeyGeneratorDlg::OnSysCommand( UINT nID, LPARAM lParam)
{
if ( ( nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout ;
dlgAbout.DoModal() ;
}
else {
CDialogEx::OnSysCommand( nID, lParam) ;
}
}
//----------------------------------------------------------------------------
void
CKeyGeneratorDlg::OnPaint( void)
{
if ( IsIconic()) {
CPaintDC dc( this) ; // device context for painting
SendMessage( WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0) ;
// Center icon in client rectangle
int cxIcon = GetSystemMetrics( SM_CXICON) ;
int cyIcon = GetSystemMetrics( SM_CYICON) ;
CRect rect ;
GetClientRect( &rect) ;
int x = ( rect.Width() - cxIcon + 1) / 2 ;
int y = ( rect.Height() - cyIcon + 1) / 2 ;
// Draw the icon
dc.DrawIcon( x, y, m_hIcon) ;
}
else {
CDialogEx::OnPaint() ;
}
}
//----------------------------------------------------------------------------
HCURSOR
CKeyGeneratorDlg::OnQueryDragIcon( void)
{
return static_cast<HCURSOR>( m_hIcon) ;
}
//----------------------------------------------------------------------------
void
CKeyGeneratorDlg::OnCancel( void)
{
}
//----------------------------------------------------------------------------
void
CKeyGeneratorDlg::OnClose( void)
{
EndDialog( IDCANCEL) ;
}
//----------------------------------------------------------------------------
void
CKeyGeneratorDlg::OnGenerate( void)
{
KeyMaker mKey ;
CStringW wszTemp ;
// recupero il cliente
GetDlgItem( IDC_CUSTOMER)->GetWindowTextW( wszTemp) ;
string sCust = wstrztoA( wszTemp) ;
if ( ! mKey.SetCustomer( sCust)) {
AfxMessageBox( L"Dati cliente vuoto o con caratteri vietati (\\/:*?\"<>|)") ;
return ;
}
WritePrivateProfileStringUtf8( "Data", "Customer", sCust.c_str(), AfxGetApp()->m_pszProfileName) ;
// recupero l'identificativo macchina (tipo 2)
GetDlgItem( IDC_MACHID)->GetWindowTextW( wszTemp) ;
string sMachId = wstrztoA( wszTemp) ;
if ( ! mKey.SetMachineId( sMachId)) {
AfxMessageBox( L"Id Macchina vuoto o errato") ;
return ;
}
WritePrivateProfileStringUtf8( "Data", "MachineId", sMachId.c_str(), AfxGetApp()->m_pszProfileName) ;
// recupero il prodotto
GetDlgItem( IDC_PROD)->GetWindowTextW( wszTemp) ;
string sProd = wstrztoA( wszTemp) ;
if ( ! mKey.SetProduct( sProd)) {
AfxMessageBox( L"Prodotto vuoto o errato") ;
return ;
}
int nSelProd = ((CComboBox*)GetDlgItem( IDC_PROD))->GetCurSel() ;
nSelProd = max( nSelProd, 0) ;
WritePrivateProfileInt( "Data", "SelProduct", nSelProd, AfxGetApp()->m_pszProfileName) ;
// recupero la versione
GetDlgItem( IDC_VER)->GetWindowTextW( wszTemp) ;
string sVer = wstrztoA( wszTemp) ;
if ( ! mKey.SetVersion( sVer)) {
AfxMessageBox( L"Versione vuota o errata") ;
return ;
}
int nSelVer = ((CComboBox*)GetDlgItem( IDC_VER))->GetCurSel() ;
nSelVer = max( nSelVer, 0) ;
WritePrivateProfileInt( "Data", "SelVer", nSelVer, AfxGetApp()->m_pszProfileName) ;
// recupero il livello
GetDlgItem( IDC_LEV)->GetWindowTextW( wszTemp) ;
string sLev = wstrztoA( wszTemp) ;
if ( ! mKey.SetLevel( sLev)) {
AfxMessageBox( L"Livello vuoto o errato") ;
return ;
}
int nSelLev = ((CComboBox*)GetDlgItem( IDC_LEV))->GetCurSel() ;
nSelLev = max( nSelLev, 0) ;
WritePrivateProfileInt( "Data", "SelLev", nSelLev, AfxGetApp()->m_pszProfileName) ;
// recupero la data di scadenza
int nDays ;
CTime tTime ;
if ( ((CDateTimeCtrl*)GetDlgItem( IDC_EXPIRATION))->GetTime( tTime) == GDT_VALID)
nDays = int( tTime.GetTime() / ( 24 * 3600)) ;
else
nDays = - 1 ;
if ( ! mKey.SetExpirDays( nDays)) {
AfxMessageBox( L"Inserisci una Data valida") ;
return ;
}
WritePrivateProfileInt( "Data", "ExpTime", int( tTime.GetTime()), AfxGetApp()->m_pszProfileName) ;
// recupero le opzioni
unsigned int nOpt1 = 0 ;
for ( int i = IDC_CHECK01, j = 0 ; i <= IDC_CHECK16 ; ++ i, ++ j) {
if ( ((CButton*)GetDlgItem( i))->GetCheck() == BST_CHECKED)
nOpt1 += ( 1 << j) ;
}
unsigned int nOpt2 = 0 ;
if ( ! mKey.SetOptions( nOpt1, nOpt2)) {
AfxMessageBox( L"Inserisci Opzioni valide") ;
return ;
}
// recupero la data di scadenza delle opzioni
int nOptDays ;
CTime tOptTime ;
if ( ((CDateTimeCtrl*)GetDlgItem( IDC_OPT_EXPIR))->GetTime( tOptTime) == GDT_VALID)
nOptDays = int( tOptTime.GetTime() / ( 24 * 3600)) ;
else
nOptDays = - 1 ;
if ( ! mKey.SetOptExpirDays( nOptDays)) {
AfxMessageBox( L"Inserisci una Data valida per le opzioni") ;
return ;
}
// calcolo la chiave
if ( ! mKey.CalcKey()) {
AfxMessageBox( L"Errore nel calcolo della chiave") ;
return ;
}
string sKey ;
mKey.GetKey( sKey) ;
// salvo i dati
if ( ! mKey.SaveData())
AfxMessageBox( L"Errore nel salvataggio dei dati") ;
// visualizzo i risultanti
CKeyDlg dlgKey( sKey) ;
dlgKey.DoModal() ;
}
+39
View File
@@ -0,0 +1,39 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : KeyGeneratorDlg.cpp Data : 11.09.14 Versione : 1.5i2
// Contenuto : Dichiarazione della classe dialogo generatore chiavi.
//
//
//
// Modifiche : 11.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
//----------------------------------------------------------------------------
// CKeyGeneratorDlg dialog
class CKeyGeneratorDlg : public CDialogEx
{
public :
CKeyGeneratorDlg( CWnd* pParent = NULL) ;
protected:
virtual void OnCancel( void) ;
afx_msg void OnClose( void) ;
afx_msg void OnGenerate( void) ;
protected :
virtual BOOL OnInitDialog( void) ;
afx_msg void OnSysCommand( UINT nID, LPARAM lParam) ;
afx_msg void OnPaint( void) ;
afx_msg HCURSOR OnQueryDragIcon( void) ;
protected :
HICON m_hIcon ;
DECLARE_MESSAGE_MAP()
} ;
+191
View File
@@ -0,0 +1,191 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : KeyProcess.cpp Data : 11.09.14 Versione : 1.5i2
// Contenuto : Implementazione funzioni costruzione chiave.
//
//
//
// Modifiche : 11.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "KeyMaker.h"
#include "/EgtDev/Include/SELkMachineId.h"
#include "/EgtDev/Include/SELkKeyProc.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtIniFile.h"
#include <fstream>
using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//----------------------------------------------------------------------------
KeyMaker::KeyMaker( void)
{
m_sCustomer.clear() ;
m_sMachineId.clear() ;
m_sMachineId2.clear() ;
m_sScramKey.clear() ;
m_nProd = 0 ;
m_nVer = 0 ;
m_nLev = 0 ;
m_nExpDays = 0 ;
m_nOpt1 = 0 ;
m_nOpt2 = 0 ;
m_nOptExpDays = 0 ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetCustomer( const string& sCustomer)
{
// verifico validità nome come nome di file
if ( ! IsValidName( sCustomer))
return false ;
m_sCustomer = sCustomer ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetMachineId( const string& sMachineId2)
{
// calcolo identificativo macchina in chiaro
string sMachineId ;
if ( ! ConvertMachineId2ToMachineId( sMachineId2, sMachineId))
return false ;
// calcolo chiave di scramble
string sScramKey ;
if ( ! ConvertMachineId2ToScramKey( sMachineId2, sScramKey))
return false ;
m_sMachineId2 = sMachineId2 ;
m_sMachineId = sMachineId ;
m_sScramKey = sScramKey ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetProduct( const std::string& sProd)
{
int nProd ;
if ( ! FromString( sProd, nProd) ||
nProd < 100 || nProd > 9999)
return false ;
m_nProd = nProd ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetVersion( const std::string& sVer)
{
int nVer ;
if ( ! FromString( sVer, nVer) ||
nVer < 15 || nVer > 99)
return false ;
m_nVer = nVer ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetLevel( const std::string& sLev)
{
int nLev ;
if ( ! FromString( sLev, nLev) ||
nLev < 1 || nLev > 99)
return false ;
m_nLev = nLev ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetExpirDays( int nExpDays)
{
if ( nExpDays < 0 || nExpDays > 999999)
return false ;
m_nExpDays = nExpDays ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetOptions( unsigned int nOpt1, unsigned int nOpt2)
{
m_nOpt1 = nOpt1 ;
m_nOpt2 = nOpt2 ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SetOptExpirDays( int nOptExpDays)
{
if ( nOptExpDays < 0 || nOptExpDays > 999999)
return false ;
m_nOptExpDays = nOptExpDays ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::CalcKey( void)
{
string sKey ;
if ( ! MakeKey( m_nProd, m_nVer, m_nLev, m_nExpDays,
m_nOpt1, m_nOpt2, m_nOptExpDays,
m_sScramKey, sKey))
return false ;
m_sKey = sKey ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::GetKey( string& sKey)
{
if ( m_sKey.empty())
return false ;
sKey = m_sKey ;
return true ;
}
//----------------------------------------------------------------------------
bool
KeyMaker::SaveData( void)
{
// determino path file di salvataggio
string sDataDir = GetPrivateProfileStringUtf8( "General", "DataDir", "C:/EgtProg/KeyGenerator", AfxGetApp()->m_pszProfileName) ;
TrimRight( sDataDir, "/\\") ;
string sFile = sDataDir + "/" + m_sCustomer + ".Kge" ;
// apro il file
ofstream ofOut( stringtoW( sFile), ios_base::out | ios_base::app) ;
if ( ! ofOut.good())
return false ;
// inserisco la data
ofOut << CurrDateTime() << endl ;
ofOut << "Customer=" << m_sCustomer << endl ;
ofOut << "MachineId=" << m_sMachineId2 << endl ;
ofOut << "ClearMachineId=" << m_sMachineId << endl ;
ofOut << "Product=" << m_nProd << endl ;
ofOut << "Ver=" << m_nVer << endl ;
ofOut << "Lev=" << m_nLev << endl ;
ofOut << "ExpDays=" << m_nExpDays << endl ;
ofOut << "Opt1=" << m_nOpt1 << endl ;
ofOut << "Opt2=" << m_nOpt2 << endl ;
ofOut << "OptExpDays=" << m_nOptExpDays << endl ;
ofOut << "Key=" << m_sKey << endl ;
// chiudo il file
ofOut.close() ;
return true ;
}
+49
View File
@@ -0,0 +1,49 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : KeyGeneratorDlg.cpp Data : 11.09.14 Versione : 1.5i2
// Contenuto : Dichiarazione della classe dialogo generatore chiavi.
//
//
//
// Modifiche : 11.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include <string>
//----------------------------------------------------------------------------
// KeyMaker class
class KeyMaker
{
public :
KeyMaker(void) ;
bool SetCustomer( const std::string& sCustomer) ;
bool SetMachineId( const std::string& sMachineId2) ;
bool SetProduct( const std::string& sProd) ;
bool SetVersion( const std::string& sVer) ;
bool SetLevel( const std::string& sLev) ;
bool SetExpirDays( int nExpDays) ;
bool SetOptions( unsigned int nOpt1, unsigned int nOpt2) ;
bool SetOptExpirDays( int nOptExpDays) ;
bool CalcKey( void) ;
bool GetKey( std::string& sKey) ;
bool SaveData( void) ;
private :
std::string m_sCustomer ;
std::string m_sMachineId ;
std::string m_sMachineId2 ;
std::string m_sScramKey ;
std::string m_sKey ;
int m_nProd ;
int m_nVer ;
int m_nLev ;
int m_nExpDays ;
unsigned int m_nOpt1 ;
unsigned int m_nOpt2 ;
int m_nOptExpDays ;
} ;
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.
BIN
View File
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// KeyGenerator.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
+56
View File
@@ -0,0 +1,56 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "/EgtDev/Include/EgtTargetVer.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#include "/EgtDev/Include/EgtLibVer.h"
#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "SEgtLock" EGTLIBVER ".lib")
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
+8
View File
@@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>