2016年11月8日 星期二

[C++]CStdioFile, GetModuleFileName, _taccess, std::map

CStdioFile readFile;

CString strLine;

 

CString pthToolDir;

CString csMsg;

std::map < int, CString> map_HAL_Error;

 

::GetModuleFileName(NULL, pthToolDir.GetBuffer(MAX_PATH), MAX_PATH);

pthToolDir.ReleaseBuffer();

pthToolDir = pthToolDir.Left(pthToolDir.ReverseFind('\\'));

CString path_ErrList = pthToolDir + _T("\\_ErrList.txt");

 

if ( _taccess(path_ErrList, 0) != 0)

{

        csMsg.Format("%s access fail", path_ErrList);

        m_strMessage = csMsg;

        AfxMessageBox(m_strMessage.c_str());

        TraceLog(MSG_ERROR, m_strMessage);     

        return false;

}

 

readFile.Open(path_ErrList , CFile::modeRead);

readFile.SeekToBegin();

 

 

int nCount = 0;

while(readFile.ReadString(strLine))

{

        if (strLine.Find(_T("(HAL Error)")) != -1 ){

                nCount = 0;

                while(readFile.ReadString(strLine))

                {

                        if(strLine.GetLength( ) == 0 ) break;

                        map_HAL_Error.insert( pair<int,CString >(nCount, strLine));

                        nCount++;

                }

                m_strMessage = "readFileErrList, (HAL Error) ok";

                TraceLog(MSG_ERROR, m_strMessage);     

        }

}

**********************Confidentiality Notice************************
The opinions and views expressed in this e-mail are solely those of the author and do not necessarily represent our company and its affiliates. If this e-mail is not originally intended for you, or received by you in error, do not disclose its content to anyone and delete it immediately. This e-mail may contain information that is legally privileged, confidential or exempt from disclosure.

沒有留言:

張貼留言