读取文件

CFile ReadFile;
if (ReadFile.Open(strPath, CFile::modeRead) == FALSE) {
     
MessageBeep((WORD)-1);
MessageBox("打开文件失败!", "警告", MB_ICONWARNING);
return;
}
CArchive ar(&ReadFile, CArchive::load);
int posserver = 0;//用于服务器数量循环
int posgroup = 0;//用于组数量循环

int m_ServerNumber;//服务器数量
ar >> m_ServerNumber;//杜文将将值放到变量中
for (posserver = 0; posserver < m_ServerNumber; posserver++)
{
     
    CString m_ServerName;//服务器名称
    ar >> m_ServerName;
    
    int m_OPC_Svr_Type;//服务器连接状态
    ar >> m_OPC_Svr_Type;
    
    CString m_sIP;//若链接远程 IP地址
    if (m_OPC_Svr_Type == 1)
    {
     
    ar >> m_sIP;
    }
    
    int m_GroupNumber;//组的数量
    ar >> m_GroupNumber;
    
    for (posgroup = 0; posgroup < m_GroupNumber; m_GroupNumber++)
    {
     
        //读取组得速率
        ar >> m_OPCClientCard->OPCClient_Unadjustable.OPC_Group_Refrate;
         //读取组得死区
        ar >> m_OPCClientCard->OPCClient_Unadjustable.OPC_Group_Dead;
        //读取点的数量
        ar >> m_PointNumber->iAVReadAndWriteTagNumber >> m_PointNumber->iAVOnlyReadTagNumber;
        ar >> m_PointNumber->iAVOnlyWriteTagNumber >> m_PointNumber->iDVReadAndWriteTagNumber;
        ar >> m_PointNumber->iDVOnlyReadTagNumber >> m_PointNumber->iDVOnlyWriteTagNumber;
        //该函数是用来计算总点数
        int allpointnumber = m_PointNumber->GetAllNumber();
        int posallpoint = 0;//用于点数循环得变量
        for (posallpoint = 0; posallpoint < allpointnumber; posallpoint++)
        {
     
        	ar >> m_PointTag->csSavedItem_TagName;//读取点标签
        }
    }
}

你可能感兴趣的:(读取文件)