please try as below
CFile obFile;
BOOL bResult = FALSE;
CWinApp* pApp = AfxGetApp();
if( obFile.Open( strAppIniPath, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite ))
{
AfxMessageBox(_T("File Opened"),IDOK,NULL);
bResult = pApp->WriteProfileString(_T("General"), _T("FirstName"), _T("ABC"));
if(bResult)
AfxMessageBox(_T("Text Written"),IDOK,NULL);
else
AfxMessageBox(_T("Text not Written"),IDOK,NULL);
bResult = pApp->WriteProfileString(_T("General"),_T("LastName"), _T("XYZ"));
if(bResult)
AfxMessageBox(_T("Text Written"),IDOK,NULL);
else
AfxMessageBox(_T("Text not Written"),IDOK,NULL);
}
else
AfxMessageBox(_T("Unable to Open File"),IDOK,NULL);