Compatibility: 3.0+
Expects: AX    5c00H
CX:DX file offset from start of file    (CX * 65536)+DX
SI:DI length in bytes of region to lock (SI * 65536)+DI
Returns: AX    error code if CF is set to CY
Info: This function locks access to a region of the file identified by
the file handle in BX.  The region of the file that begins at
file logical offset CX:DX extending for a length of SI:DI is

File sharing support must be present (usually installed by your
network software, or Windows, or by using the DOS Share command).
If not installed, the call returns an error code of "invalid
function number."

Locks apply to reads, writes, and opens of a file by a child or
concurrent process.  When another process attempts such an access
(and the Access Mode defined during the file OPEN is a sharing
mode which disallows such access), then DOS will fail the
operation via an INT 24H Critical Error handler.

The correct way to avoid a lock violation is to attempt to lock
the region yourself and examine the returned error code.  By
default, any attempt to violate a lock causes DOS to display the
"Abort, Retry, Ignore" message after three tries.  You can change
the retry count via fn 440bH.  And you can intercept INT 24H to
cause a less ghastly response.

To lock an entire file: It is legal to lock beyond the end of the
file.  You can lock an entire file by setting CX=0, DX=0,
SI=0ffffH, and DI=0ffffH.

Notes:   When you unlock (via fn 5c01H), the offset and length must
match exactly with the offset and length that was locked.

  DUPing a file handle via Fn 45H or 46H will duplicate any

  Even if an Access Mode of "Inherit" is used when opened, the
locking mechanism does not give access privileges to child
processes created via 4bH EXEC.

  It is important that all locks be removed from a file before a
program is terminated.  You should intercept INT 23H
(Ctrl-Break) and INT 24H (Critical Error) to ensure that locks
are removed before you terminate.

  It is recommended that you unlock as soon as possible.  Always
try to lock, access the file, and unlock in one operation.

- -

DOS Fn 5c00H: Lock File Access