📄 xlhscqdlg.cpp
字号:
// xlhscqDlg.cpp : implementation file
//
#include "stdafx.h"
#include "xlhscq.h"
#include "xlhscqDlg.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXlhscqDlg dialog
CXlhscqDlg::CXlhscqDlg(CWnd* pParent /*=NULL*/)
: CDialog(CXlhscqDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CXlhscqDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CXlhscqDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CXlhscqDlg)
DDX_Control(pDX, IDC_SRWKH, m_Srwkh);
DDX_Control(pDX, IDC_XLH5, m_Xlh5);
DDX_Control(pDX, IDC_XLH4, m_Xlh4);
DDX_Control(pDX, IDC_XLH3, m_Xlh3);
DDX_Control(pDX, IDC_XLH2, m_Xlh2);
DDX_Control(pDX, IDC_XLH1, m_Xlh1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CXlhscqDlg, CDialog)
//{{AFX_MSG_MAP(CXlhscqDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDOK2, OnOk2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXlhscqDlg message handlers
BOOL CXlhscqDlg::OnInitDialog()
{
CDialog::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)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CXlhscqDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CXlhscqDlg::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 CXlhscqDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CXlhscqDlg::OnOK()
{
CDialog::OnOK();
}
void CXlhscqDlg::OnOk2()
{
//下一段生成序列号,序列号共5组字符,每组5个,
//取序列号的第2、3、4组的前四个字符组成12位的字符串
//将网卡地址经加密后与生成该组字符串。
CString test;
int bb1,bb2,i;
char *xor = "913862415749"; //生成密钥
char wkdz[13],xlh1[6],xlh2[6],xlh3[6],xlh4[6],xlh5[6],test1[30];
memset(test1,0,sizeof(test1));
memset(wkdz,0,sizeof(wkdz));
//0J0D-J07L-9JH5-a5CH-4b90-795c
m_Srwkh.GetWindowText(test);
/*
网卡的实际地址:wkdz[0-11]的每位的值分别是1、2、3、4、5、6、7、8、9、A、B、C
则:test1=1X2X-X34X-5XX6-78XX-X9XA-BXXC
*/
sprintf(test1,"%s",test);
wkdz[0]=test1[0];
wkdz[1]=test1[2];
wkdz[2]=test1[6];
wkdz[3]=test1[7];
wkdz[4]=test1[10];
wkdz[5]=test1[13];
wkdz[6]=test1[15];
wkdz[7]=test1[16];
wkdz[8]=test1[21];
wkdz[9]=test1[23];
wkdz[10]=test1[25];
wkdz[11]=test1[28];
wkdz[13]='0';
// sprintf(wkdz,"%s",test);
// if(strlen(wkdz)!=12)
// AfxMessageBox("网卡地址位长错误\n请输入12位网卡号");
if(strlen(test1)!=29)
AfxMessageBox("机器码位长错误!\n请输入29位机器码,包含符号\"-\"");
else
{
//随机生成序列号1
memset(xlh1,0,sizeof(xlh1));
bb1 = rand()%100;
bb2 = rand()%1000;
sprintf(xlh1,"%5d",bb1*bb2);
// xlh1[5] = 0;
for(i = 0; i < 5; i++)
{
xlh1[i] = xlh1[i] + xor[i]; //数字转换为字母
}
m_Xlh1.SetWindowText(AnsiUpper(xlh1));
//随机生成序列号5
memset(xlh5,0,sizeof(xlh5));
bb1 = rand()%100;
bb2 = rand()%1000;
sprintf(xlh5,"%5d",bb1*bb2);
// xlh5[5] = 0;
for(i = 0; i < 5; i++)
{
xlh5[i] = xlh5[i] + xor[i]; //数字转换为字母
}
m_Xlh5.SetWindowText(AnsiUpper(xlh5));
//生成序列号2、3、4
for(i = 0; i < 12; i++)
{
if(!IsCharAlpha(wkdz[i]))
wkdz[i] = wkdz[i] + xor[i]; //数字转换为字母
}
memset(xlh2,0,sizeof(xlh2));
memset(xlh3,0,sizeof(xlh3));
memset(xlh4,0,sizeof(xlh4));
memcpy(xlh2,wkdz,4);
xlh2[4] = xlh1[2];
m_Xlh2.SetWindowText(AnsiUpper(xlh2));
memcpy(xlh3,wkdz+4,4);
xlh3[4] = xlh1[2];
m_Xlh3.SetWindowText(AnsiUpper(xlh3));
memcpy(xlh4,wkdz+8,4);
xlh4[4] = xlh1[2];
m_Xlh4.SetWindowText(AnsiUpper(xlh4));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -