This QC report say that Delphi doesn't support the file sharing mode FILE_SHARE_DELETE
http://qc.embarcadero.com/wc/qcmain.aspx?d=45628
I need to use this mode with TFileStreams - Can anyone think of a straightforward workaround that doesn't involve modifying the library code, or duplicating reams of stuff from the library?
The QC report is correct. TFileStream
(more specifically, the SysUtils.FileOpen()
function) does not support FILE_SHARE_DELETE
. It only supports FILE_SHARE_READ
and FILE_SHARE_WRITE
.
In order to use sharing rights beyond what TFileStream
natively supports, you will have to call the Win32 API CreateFile()
function directly, then you can construct a THandleStream
object using the handle that CreateFile()
returns.