?? sernumdlg.cpp
字號:
// sernumDlg.cpp : implementation file
//
#include "stdafx.h"
#include "sernum.h"
#include "sernumDlg.h"
#include "Crypto.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSernumDlg dialog
CSernumDlg::CSernumDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSernumDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSernumDlg)
m_cardnum1 = _T("");
m_cardnum2 = _T("");
m_cardnum3 = _T("");
m_cardnum4 = _T("");
m_finalnum1 = _T("");
m_finalnum2 = _T("");
m_finalnum3 = _T("");
m_finalnum4 = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSernumDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSernumDlg)
DDX_Text(pDX, IDC_EDIT1, m_cardnum1);
DDX_Text(pDX, IDC_EDIT2, m_cardnum2);
DDX_Text(pDX, IDC_EDIT3, m_cardnum3);
DDX_Text(pDX, IDC_EDIT4, m_cardnum4);
DDX_Text(pDX, IDC_STATIC1, m_finalnum1);
DDX_Text(pDX, IDC_STATIC2, m_finalnum2);
DDX_Text(pDX, IDC_STATIC3, m_finalnum3);
DDX_Text(pDX, IDC_STATIC4, m_finalnum4);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSernumDlg, CDialog)
//{{AFX_MSG_MAP(CSernumDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTONONE, OnButtonone)
ON_BN_CLICKED(IDC_BUTTONTWO, OnButtontwo)
ON_BN_CLICKED(IDC_BUTTONTHREE, OnButtonthree)
ON_BN_CLICKED(IDC_BUTTONFOUR, OnButtonfour)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSernumDlg message handlers
BOOL CSernumDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSernumDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (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
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSernumDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSernumDlg::OnButtonone()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString instring,outstring;
instring=m_cardnum1;
GetSerNum(instring,outstring);
// GetSerNum(_T("0040"),outstring);
// GetSerNum(_T("0040"),outstring);
// GetSerNum(_T("0040"),outstring);
m_finalnum1=outstring;
UpdateData(FALSE);
}
void CSernumDlg::OnButtontwo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString instring,outstring;
instring=m_cardnum2;
BYTE indata[24],outdata[20];
int i,len,ilen;
len=instring.GetLength();
i=0;
while(i<len)
{
indata[i]=instring.GetAt(i);
i++;
}
ilen=i;
while(i<24)
indata[i++]=0;
int re=GetSerNum(indata,outdata,ilen,20);
if(re<0) return;
for(i=0;i<20;i++)
outstring.Insert(i+1,outdata[i]);
m_finalnum2=outstring;
UpdateData(FALSE);
}
void CSernumDlg::OnButtonthree()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString instring,outstring;
instring=m_cardnum3;
GetSerNum(instring,outstring);
m_finalnum3=outstring;
UpdateData(FALSE);
}
void CSernumDlg::OnButtonfour()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString instring,outstring;
instring=m_cardnum4;
GetSerNum(instring,outstring);
m_finalnum4=outstring;
UpdateData(FALSE);
}
void CSernumDlg::GetSerNum(CString inputstring, CString &outputstring)
{
CCrypto* pcrypto=new CCrypto;
pcrypto->GetFinalData(inputstring,outputstring);
pcrypto->~CCrypto();
}
int CSernumDlg::GetSerNum(BYTE inputdata[], BYTE outputdata[], int inputSize, int outputSize)
{
CCrypto* pcrypto=new CCrypto;
int returnnum;
returnnum=pcrypto->GetFinalData(inputdata,outputdata,inputSize,outputSize);
pcrypto->~CCrypto();
return(returnnum);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -