📄 password.cpp
字号:
// Password.cpp : implementation file
//
#include "stdafx.h"
#include "cdms.h"
#include "Password.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPassword dialog
CPassword::CPassword(CWnd* pParent /*=NULL*/)
: CDialog(CPassword::IDD, pParent)
{
//{{AFX_DATA_INIT(CPassword)
m_strPassword = _T("");
//}}AFX_DATA_INIT
m_nErrorTime = 0;
}
void CPassword::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPassword)
DDX_Control(pDX, IDC_EDIT_PASSWORD, m_ctrlPassword);
DDX_Text(pDX, IDC_EDIT_PASSWORD, m_strPassword);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPassword, CDialog)
//{{AFX_MSG_MAP(CPassword)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPassword message handlers
void CPassword::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
//查询有关的数据
char charPassword[50];
CString strPassword;
CString strKey;
strKey.Format("HKEY_CURRENT_USER\\动力厂鼓风机");
::GetProfileString(strKey,"Password","",charPassword,50);
strPassword = charPassword;
if(strPassword == "")
{
int i=AfxMessageBox("初始密码不存在,把这次输入作为初始密码吗?",MB_YESNO);
if(i==IDYES)
{
::WriteProfileString(strKey,"Password",m_strPassword);
CString str="密码为"+m_strPassword;
AfxMessageBox(str,MB_OK);
CDialog::OnOK();
return;
}
else
{
CDialog::OnCancel();
// _exit(1);
}
}
else if(strPassword == m_strPassword)
{
CDialog::OnOK();
}
else
{
int i=AfxMessageBox("密码错误请重试!",MB_OK);
if(i==IDOK)
{
m_nErrorTime++;
if(m_nErrorTime == 3)
{
AfxMessageBox("密码输入三次错误,请跟系统管理员联系!",MB_OK);
CDialog::OnCancel();
// _exit(1);
}
m_ctrlPassword.SetFocus();
m_ctrlPassword.SetSel(0,m_strPassword.GetLength(),FALSE);
}
else
{
CDialog::OnCancel();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -