// SetPwd.cpp : implementation file
//
#include "stdafx.h"
#include "play.h"
#include "SetPwd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CSetPwd dialog
CSetPwd::CSetPwd(CWnd* pParent /*=NULL*/)
: CDialog(CSetPwd::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetPwd)
m_Pwd = _T("");
m_SurePwd = _T("");
//}}AFX_DATA_INIT
}
void CSetPwd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetPwd)
DDX_Text(pDX, IDC_SETPWD, m_Pwd);
DDX_Text(pDX, IDC_SUREPWD, m_SurePwd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetPwd, CDialog)
//{{AFX_MSG_MAP(CSetPwd)
ON_BN_CLICKED(IDC_OK, OnOk)
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CSetPwd message handlers
BOOL CSetPwd::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CWnd* pWnd=GetDlgItem(IDC_SETPWD);
pWnd->SetFocus();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSetPwd::OnOk()
{
// TODO: Add your control notification handler code here
char * m_Passwd;
UpdateData(TRUE);
m_Passwd=m_Pwd.GetBuffer(50);
m_Pwd.ReleaseBuffer();
if((strcmp(m_Pwd,m_SurePwd))!=0)
{
MessageBox("设置不对,请重新输入");
CWnd* pWnd1=GetDlgItem(IDC_SETPWD);
pWnd1->SetWindowText("");
pWnd1->SetFocus();
CWnd* pWnd2=GetDlgItem(IDC_SUREPWD);
pWnd2->SetWindowText("");
}
if((strcmp(m_SurePwd,m_Pwd))==0)
{
if((RegSetValueEx(PasswdKey,"Passwd",
0,REG_SZ,(CONST BYTE*)m_Passwd,strlen(m_Pwd)+1))==ERROR_SUCCESS)
{
RegFlushKey(PasswdKey);
RegCloseKey(PasswdKey);
}
else
fail=TRUE;
CDialog::OnCancel();
}
}
void CSetPwd::OnCancel()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
fail=TRUE;
}