char szReturn[255];
memset(szReturn,0,255);
int nReLen=GetPrivateProfileString   (sSection,sKey,sDefault,szReturn,255,sFilename);
szReturn[nReLen] ='\0';

解决方案 »

  1.   

    GetPrivateProfileString
    WritePrivateProfileString
      

  2.   

    楼上仁兄告诉你的是用于读配置文件所用的函数,以及回写配置文件的函数;
    如果你有什么不懂,你可以在MSDN里面查阅详细的关于以上函数的说明!
      

  3.   

    #include "stdafx.h"
    #include "profile.h"//建议用Singleton模式,维护一个全局的配置文件读写类。CProfile:: CProfile(LPTSTR fileName){
    strcpy(m_lptsFileName,fileName);//建议用strncpy,防止内存越界
    m_iEntryLength=50;//
    }void CProfile:: setFileName(LPTSTR fileName){
    strcpy(m_lptsFileName,fileName); 
    m_iEntryLength=16;
     };void CProfile:: setEntryLength(int i){
            m_iEntryLength=i;
    }
    long CProfile:: getIntEntryValue(LPCTSTR lpctSectionName , LPCTSTR lpctEntryName){
    int iValueLength=0;
    iValueLength=GetPrivateProfileString(lpctSectionName,lpctEntryName,"",lpszTempVal,m_iEntryLength,m_lptsFileName);
    long i=(long)strtol(lpszTempVal,NULL,10);
    return i;
    }; int CProfile:: getEntryValue(LPTSTR lpValue, LPCTSTR lpctSectionName , LPCTSTR lpctEntryName) {  
     int iValueLength=0;
     iValueLength=GetPrivateProfileString(lpctSectionName,lpctEntryName,"NULL",
     lpValue,sizeof(lpValue),m_lptsFileName);
     return iValueLength;
    }
    int CProfile:: getEntryValue(LPTSTR lpValue,INT iLength,LPCTSTR lpctSectionName , LPCTSTR lpctEntryName) {  
     int iValueLength=0;
     iValueLength=GetPrivateProfileString(lpctSectionName,lpctEntryName,"NULL",
     lpValue,iLength,m_lptsFileName);
     return iValueLength;
    }BOOL CProfile:: setEntryValue(LPCTSTR lpctSectionName ,  LPCTSTR lpctEntryName, LPCTSTR  lpsctValue) {
        if (!WritePrivateProfileString(lpctSectionName,lpctEntryName,lpsctValue,m_lptsFileName))
          return FALSE;
    return TRUE;
     }
    这是别人写的一个配置文件的读写类,头文件我没有写,你自己写吧。