void myProgram
{
CStdioFile file;
CString szPath = _T("Myfile.txt");
CString szData,szError;
bool bFound = false;
int nErrors = 0;
TCHAR szCause[255];
try
{
file.Open(szPath, CFile::modeNoTruncate | CFile::modeReadWrite);
file.SeekToEnd();
while( file.ReadString(szData) && !bFound && !nErrors )
{
if( szData.Find(_T("MyName="),0) >= 0 )
{
someProcessProgram(szData);
bFound = true;
}
}
file.Close();
}
catch( CException* e )
{
e->GetErrorMessage(szCause,255);
e->Delete();
szError.Format(_T("An exception occurred while reading data.\nWindows reports: %s"),szCause);
nErrors++;
AfxMessageBox(szError);
}
catch( std::exception* e )
{
szError.Format(_T("An exception occurred while reading data.\nWindows reports: %s"),e->what());
nErrors++;
AfxMessageBox(szError);
}
catch(...)
{
szError = _T("An exception occurred while reading data.");
nErrors++;
AfxMessageBox(szError);
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.