眼下本人考虑到部门配置文件较多,所以想写个配置文件检測程序.
眼下大致的思路例如以下三部分;
1, 读取配置文件的内容(*.ini).
查找配置文件,代码例如以下
void CDataBaseDlg::OnSelectConfigParth()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
static char BASED_CODE szFilter[] = "Config Files (*.ini)|*.ini||";
CFileDialog dlgFile(TRUE, NULL, NULL, OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY,szFilter, NULL);
if(dlgFile.DoModal() ==IDOK )
{
GetDlgItem(IDC_EDIT1)->SetWindowText(dlgFile.GetPathName());
GetDlgItem(IDC_EDIT1)->GetWindowText(m_ConfigPath);
CString Str=m_ConfigPath;
}
}
读取配置文件的内容例如以下;
void CDataBaseDlg::OnButton2()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
char Buffer[100];
memset(Buffer, 0x00, sizeof(Buffer));
GetPrivateProfileString ("StartAndEndIP", "StartIp", "0.0.0.0", Buffer, 100,m_ConfigPath);
GetDlgItem(IDC_EDIT2)->SetWindowText(Buffer);
/*memset(Buffer, 0x00, sizeof(Buffer));
GetPrivateProfileString ("StartAndEndIP", "EndIp", "0.0.0.0", Buffer, 100, m_ConfigPath);
GetDlgItem(IDC_EDIT4)->SetWindowText(Buffer);}*/
}
2.查找存储在数据中的配置文件信息.(代码日后供上)
3.1中读取的内容与数据库中查找的内容相比較,哪一项不匹配就报告哪一项失败.(代码日后供上)