VC讀取和寫入配置文件

        char CDstr[MAX_PATH];
TCHAR IniFilePath[MAX_PATH];
GetModuleFileName(NULL,IniFilePath,MAX_PATH);
m_strFileName = CString(IniFilePath);


m_strFileName = m_strFileName.Left(m_strFileName.ReverseFind('\\'));///得到初始化文件的全路徑
m_strFileName += "\\Rulecfg.cfg";


iPcPort = GetPrivateProfileInt("PC_PARA","PC_PORT",1000,m_strFileName);
GetPrivateProfileString("PC_PARA","PC_IP","",CDstr,64,m_strFileName);
strPcIp = CDstr;



m_DspNum = GetPrivateProfileInt("DSP_PARA","DSP_NUM",1,m_strFileName);
iDspDelayTime = GetPrivateProfileInt("DSP_PARA","DSP_DELAY_TIME",5,m_strFileName);
GetPrivateProfileString("DSP_PARA","IMAGE_POSITION","",CDstr,64,m_strFileName);
strAppPosition = CDstr;

//////////////////////////////////////////////////////////////////////////////寫入配置文件///////////////////////////////////////////////////////////////////////


              strSecName.Format("DSP%d_RULE_PARA",m_DspIndex+1);
strKeyPrefix.Format("DSP%d_",m_DspIndex+1);
//////////////////////DSP信息
str.Format("%d",m_tdp2[m_DspIndex].l32Width);
WritePrivateProfileString(strSecName,strKeyPrefix+"IMAGE_WIDTH",str,m_strFileName);
str.Format("%d",m_tdp2[m_DspIndex].l32Height);
WritePrivateProfileString(strSecName,strKeyPrefix+"IMAGE_HEIGHT",str,m_strFileName);
str.Format("%d",m_tdp2[m_DspIndex].l32RoiNum);
WritePrivateProfileString(strSecName,strKeyPrefix+"LANE_NUM",str,m_strFileName);



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章