禹城做网站的,怎么在自己的网站上做链接,做网站前需要做什么准备,做公司网站要钱吗新建一个dialog based MFC Windows Application,命名为#xff1a;d, 界面为#xff1a; 为按钮Read和Write添加单击事件#xff0c;并自定义一个函数GetIniFileName()用来取得ini文件的路径#xff0c;主要函数代码如下#xff1a;// read data from config file
void CD…新建一个dialog based MFC Windows Application,命名为d, 界面为 为按钮Read和Write添加单击事件并自定义一个函数GetIniFileName()用来取得ini文件的路径主要函数代码如下// read data from config file
void CDDlg::OnBtnRead() // 从INI文件中读取指定的信息更新到编辑框中
{char userName[64], password[64];int score_Chinese, score_Mathematics;CString sIniFile GetIniFileName(); // 取得配置文件全路径memset(userName, 0, sizeof(userName)); // 填充字符串数组memset(password, 0, sizeof(password));// read values from the specified config fileGetPrivateProfileString(SECTION_USERINFO, UserName, , userName, 63, sIniFile); // read a string from the specified config fileGetPrivateProfileString(SECTION_USERINFO, Password, , password, 63, sIniFile);score_Chinese GetPrivateProfileInt(SECTION_SCORE, Chinese, 0, sIniFile); // read an integer from the specified config filescore_Mathematics GetPrivateProfileInt(SECTION_SCORE, Mathematics, 0, sIniFile);// Update values to the controlsCString tempValue;((CEdit*) GetDlgItem(IDC_EDIT_USERNAME))-SetWindowText(userName);((CEdit*) GetDlgItem(IDC_EDIT_PASSWORD))-SetWindowText(password);tempValue.Format(%d, score_Chinese);((CEdit*) GetDlgItem(IDC_EDIT_CHINESE))-SetWindowText(tempValue); // 10代表十进制tempValue.Format(%d, score_Mathematics);((CEdit*) GetDlgItem(IDC_EDIT_MATHEMATICS))-SetWindowText(tempValue);MessageBox(Read data from config file successfully!, Information, MB_OK | MB_ICONINFORMATION);
// ((CStatic *) GetDlgItem(IDC_TXT_MESSAGE))-SetWindowText(Read data from config file successfully!);
}// store data to config file
void CDDlg::OnBtnwrite()
{// TODO: Add your control notification handler code herechar userName[64], password[64], sValue[20];int score_Chinese, score_Mathematics;((CEdit *) GetDlgItem(IDC_EDIT_USERNAME))-GetWindowText(userName, 63);((CEdit *) GetDlgItem(IDC_EDIT_PASSWORD))-GetWindowText(password, 63);((CEdit *) GetDlgItem(IDC_EDIT_CHINESE))-GetWindowText(sValue, 19);score_Chinese atoi(sValue);((CEdit *) GetDlgItem(IDC_EDIT_MATHEMATICS))-GetWindowText(sValue, 19);score_Mathematics atoi(sValue);// Write data to the config fileCString sIniFile GetIniFileName();CString tempValue;WritePrivateProfileString(SECTION_USERINFO, UserName, userName, sIniFile);WritePrivateProfileString(SECTION_USERINFO, Password, password, sIniFile);tempValue.Format(%d, score_Chinese);WritePrivateProfileString(SECTION_SCORE, Chinese, tempValue, sIniFile);tempValue.Format(%d, score_Mathematics);WritePrivateProfileString(SECTION_SCORE, Mathematics, tempValue, sIniFile);MessageBox(Write data to config file successfully!, Information, MB_OK | MB_ICONEXCLAMATION);
// ((CStatic *) GetDlgItem(IDC_TXT_MESSAGE))-SetWindowText(Write data to config file successfully!);
}// get the file path of config file
CString CDDlg::GetIniFileName() const
{CString Result, sPath;Result _T();char sFileName[256];GetModuleFileName(AfxGetInstanceHandle(), sFileName, 255); // 取得当前可执行文件的路径保存在sFileName中sPath sFileName;int index sPath.ReverseFind(\\); // 逆向查找指定字符sPath sPath.Left(index);Result sPath \\Config.ini;return Result;
} 其中ini文件中的内容为[UserInfo] UserNametian Password123456zhou[Score] Chinese55 Mathematics66源码下载http://d.download.csdn.net/down/2735337/JoeBlackzqq