VC++修改用户名密码函数示例代码是小编为大家整理的一个修改用户名密码函数例子,这一个函数主要用于在VC++编写的程序中,更改用户口令,更改口令对话框初始化,,赶紧来详细了解一下吧:
//名称:OnOk //功能:更改用户口令 //作者:赵权(fhiesc@163.com) void CChangePswDlg::OnOK() { UpdateData(TRUE);//读入用户输入的密码 CDBVariant varValue; CPswdSet m_recordset(&m_database); CString strSQL; strSQL.Format("select * from password where PASSWORD='%s'",m_oldpassword); m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL); //int temp=0; //m_recordset.GetFieldValue(temp,varValue); //如果输入的密码与数据库中的不一致,则弹出提示框 if(m_recordset.GetRecordCount()==0) //if(m_oldpassword.Compare(varValue.m_pstring->GetBuffer(1))!=0) { MessageBox("原密码错误!","提示",MB_OK|MB_ICONINFORMATION); m_oldpassword.Empty(); m_newpassword.Empty(); m_qurenpassword.Empty(); m_ctrloldpassword.SetFocus(); UpdateData(FALSE);//清空所输入的内容 } //如果原密码正确,两次新密码不同 else { if(m_newpassword.Compare(m_qurenpassword)!=0) { MessageBox("新密码错误!","提示",MB_OK|MB_ICONINFORMATION); m_oldpassword.Empty(); m_newpassword.Empty(); m_qurenpassword.Empty(); UpdateData(FALSE);//清空所输入的内容 } else { strSQL.Format("update password set PASSWORD='%s' where PASSWORD='%s'",m_newpassword,m_oldpassword); m_database.ExecuteSQL(strSQL); CDialog::OnOK(); MessageBox("恭喜,口令更改成功!下一次登录请使用口令: "+m_newpassword+" ","提示",MB_OK|MB_ICONINFORMATION); } } } ///////////////////////////////////////////////////////////////////////// //名称:OnInitDialog //功能:更改口令对话框初始化 //作者:赵权(fhiesc@163.com) //日期:2003.12 //////////////////////////////////////////////////////////////////////// BOOL CChangePswDlg::OnInitDialog() { CDialog::OnInitDialog(); m_ctrloldpassword.SetFocus(); return TRUE; }