VC reads the configuration file instance

  • 2020-04-02 02:49:36
  • OfStack

This article illustrates the VC reading configuration file method, to share for your reference. The specific implementation method is as follows:

char szBugCC[4096]={0};  
int nRet = GetPrivateProfileSection("Setting", szBugCC, sizeof(szBugCC), BugConfig.c_str()); 
if (nRet > 0) 

        //Filter / 0/0/00 & NBSP; < br / >         DWORD dwIndex = 0; 
        char szTemp[128]={0}; 
        while (dwIndex < nRet) 
        { 
            strcpy(szTemp, szBugCC+dwIndex); 
            //szTemp "11=11@163.com" 
            CString strTemp(szTemp); 
            int nPos = strTemp.Find("="); 
            m_combo_bugcc.AddString(strTemp.Left(nPos)); 
            dwIndex += strlen(szTemp); 
            dwIndex++; 
        } 
}

Profile format:

[Setting]  
11=11@163.cn 
22=22@163.cn 
ope=0.cn

Hope that this article described the VC programming for you to help.


Related articles: