我想做两个EDIT控件,分别表示用户名和密码,然后再用INI文件来存取用户名和密码..
每当程序运行时就去读INI文件.点击BUTTON来判断输入的用户名和密码是否与INI的用户名及密码一致,如是则返回TRUE否则返回False,请给个实例好吗?
这样方便用户修改用户名和密码..谢
每当程序运行时就去读INI文件.点击BUTTON来判断输入的用户名和密码是否与INI的用户名及密码一致,如是则返回TRUE否则返回False,请给个实例好吗?
这样方便用户修改用户名和密码..谢
MSLU supports Unicode versions of the following INI file functions.
GetPrivateProfileInt
GetPrivateProfileSection
GetPrivateProfileSectionNames
GetPrivateProfileString
GetPrivateProfileStruct
GetProfileInt
GetProfileSection
GetProfileString
WritePrivateProfileSection
WritePrivateProfileString
WritePrivateProfileStruct
WriteProfileSection
WriteProfileString
m_password在OnInitDialog中char buf[ 200 ] = "";
GetPrivateProfileString( "AAA", "name", "", buf, sizeof( buf ), "c:\\a.ini" );
m_username.SetWindowText( buf );对于m_password也是这样。
c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'其它功能未验证过,,
楼上不对的原因是因为你将Edit控件的关联变量设置成了CString型。 改为Control
[Password1]
username=abc
password=123
[Administrator]
Username = wxj
Password = wxj//在登录对话框的确认按钮响应函数中:(以验证密码为例,验证用户名同理)
UpdateData(true);
CString strPasswordTemp;GetPrivateProfileString("Administrator","Password",NULL,
strPasswordTemp.GetBuffer(50),50,".\\PASSWORD.INI");
if(m_strpassword != strPasswordTemp) //m_strpassword为密码编辑框关联的CString变量
{
MessageBox("密码错误,请重新输入! ","登录对话框",0);
m_strpassword = "";
UpdateData(false);
m_editpassword.SetFocus();
}
else
OnOK();