zoukankan      html  css  js  c++  java
  • C++中关于配置文件的问题

    眼下本人考虑到部门配置文件较多,所以想写个配置文件检測程序.

    眼下大致的思路例如以下三部分;

    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中读取的内容与数据库中查找的内容相比較,哪一项不匹配就报告哪一项失败.(代码日后供上)

  • 相关阅读:
    水平居中、垂直居中,总有一款适合你的
    HTML利用posotion属性定位 小技巧
    angular2 如何使用websocket
    angular2 引入jquery
    HTML+CSS学习笔记
    用eclipse 搭建struts2环境
    html对URL传参数进行解析
    angular2上传图片
    当div元素内的内容超出其宽度时,自动隐藏超出的内容
    关于引用对象的使用的一点小理解
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/3741069.html
Copyright © 2011-2022 走看看