CreateFile - " file is being used by another process." [modified]
-
Hi All, I am using CreateFile to open a specific file which will be accessed by multiple instance of same process simultaneously. This time function getting failed and GetLastError() is returning the following error. "The process cannot access the file because it is being used by another process." This is how i called the function
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( INVALID_HANDLE_VALUE == hFile )
{
CString csErr;
csErr.Format( _T("Failed to open File**** Error code = %d"), GetLastError());
AfxMessageBox( csErr );
return bRet;
}I need to open the same file simultaneously by different process. Please help me. -Cvaji
modified on Thursday, July 15, 2010 9:30 AM
-
Hi All, I am using CreateFile to open a specific file which will be accessed by multiple instance of same process simultaneously. This time function getting failed and GetLastError() is returning the following error. "The process cannot access the file because it is being used by another process." This is how i called the function
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( INVALID_HANDLE_VALUE == hFile )
{
CString csErr;
csErr.Format( _T("Failed to open File**** Error code = %d"), GetLastError());
AfxMessageBox( csErr );
return bRet;
}I need to open the same file simultaneously by different process. Please help me. -Cvaji
modified on Thursday, July 15, 2010 9:30 AM
-
Hi All, I am using CreateFile to open a specific file which will be accessed by multiple instance of same process simultaneously. This time function getting failed and GetLastError() is returning the following error. "The process cannot access the file because it is being used by another process." This is how i called the function
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( INVALID_HANDLE_VALUE == hFile )
{
CString csErr;
csErr.Format( _T("Failed to open File**** Error code = %d"), GetLastError());
AfxMessageBox( csErr );
return bRet;
}I need to open the same file simultaneously by different process. Please help me. -Cvaji
modified on Thursday, July 15, 2010 9:30 AM
Cvaji wrote:
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );if( INVALID_HANDLE_VALUE == hSMPFile )
The return value of the CreateFile is stored in
**hFile**
, but you have checked theINVALID_HANDLE_VALUE
aganist**hSMPFile**
file. Is it really like that in the code or its just a typo?nave [My Articles] [My Blog]
-
Hi All, I am using CreateFile to open a specific file which will be accessed by multiple instance of same process simultaneously. This time function getting failed and GetLastError() is returning the following error. "The process cannot access the file because it is being used by another process." This is how i called the function
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( INVALID_HANDLE_VALUE == hFile )
{
CString csErr;
csErr.Format( _T("Failed to open File**** Error code = %d"), GetLastError());
AfxMessageBox( csErr );
return bRet;
}I need to open the same file simultaneously by different process. Please help me. -Cvaji
modified on Thursday, July 15, 2010 9:30 AM
-
Cvaji wrote:
hFile = ::CreateFile( csFileName_i.operator LPCTSTR(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );if( INVALID_HANDLE_VALUE == hSMPFile )
The return value of the CreateFile is stored in
**hFile**
, but you have checked theINVALID_HANDLE_VALUE
aganist**hSMPFile**
file. Is it really like that in the code or its just a typo?nave [My Articles] [My Blog]