The behavior of _SH_SECURE depends on the access requested in the mode argument to _fsopen() / _wfsopen() . If only read access is requested, then _SH_SECURE mapped to FILE_SHARE_READ . Otherwise, it displays 0 (exclusive access).
The contrast is _SH_DENYWR , which is always mapped to FILE_SHARE_READ .
The corresponding portion of the CRT source code (lines 269-301 open.c in Visual Studio 2010) is as follows:
switch ( shflag ) { case _SH_DENYRW: fileshare = 0L; break; case _SH_DENYWR: fileshare = FILE_SHARE_READ; break; case _SH_DENYRD: fileshare = FILE_SHARE_WRITE; break; case _SH_DENYNO: fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE; break; case _SH_SECURE: if (fileaccess == GENERIC_READ) fileshare = FILE_SHARE_READ; else fileshare = 0L; break; default: _doserrno = 0L; *pfh = -1; _VALIDATE_RETURN_ERRCODE(( "Invalid sharing flag" , 0 ), EINVAL); }
source share