My application works on a highly sensitive file. Normally - this file is NOT shared among others and is accessed exclusively by my APP. Therefore it is opened as follows:
DWORD dwShareMode = 0; // Exclusive no share
hFile = CreateFile(
pszSrc, // file to open
GENERIC_READ | GENERIC_WRITE, // open for reading
dwShareMode, // No share!!
NULL, // default security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, // normal file
NULL); // no attr. template
However - there are certain circumstances under which my APP should allow others to read certain portions of this file. This should be carried out without any other sharing mechanism: No locks,no mutexs no nothing of that kind. In addition to that - my APP MUST keep this file open at all times. No close/re-open is applicable under the critical mission terms of this APP.
My question is: Is there a way to dynamically change the SHARE-MODE of the file associated with a handle while it is open? Practically speaking - can one open a file for EXCLUSIVE share and change it thereafter to - say - FILE_SHARE_READ | FILE_SHARE_WRITE - back and forth?
Thanks
E.