qc.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
locking
 Summary Example                         Up Contents Index Back
───────────────────────────────────────────────────────────────────────────
 
     The locking function locks or unlocks <nbyte> bytes of the file
     specified by <handle>. Locking bytes in a file prevents access to
     those bytes by other processes.
 
     All locking or unlocking begins at the current position of the
     file pointer and proceeds for the next <nbyte> bytes, or to the
     end of the file. It is possible to lock bytes past the end of the
     file.
 
     The <mode> argument specifies the locking action to be performed.
     It must be one of the following manifest constants:
 
     LK_LOCK       LK_RLCK
     LK_NBLCK      LK_UNLCK
     LK_NRBLCK
 
     More than one region of a file can be locked, but no overlapping
     regions are allowed.
 
     When a region of a file is unlocked, it must correspond to a
     region that was previously locked. The locking function does not
     merge adjacent regions; if two locked regions are adjacent, each
     region must be unlocked separately.
 
     Regions should be locked only briefly and should be unlocked
     before closing a file or exiting the program.
 
     The locking function should be used only under OS/2 or under DOS
     versions 3.0 or later; it has no effect under earlier versions of
     DOS. Note that under DOS versions 3.0 and 3.1, the files locked by
     a parent process may become unlocked when one of its children
     exits.
 
     File sharing must be loaded to use the locking function. File
     sharing is automatically loaded under OS/2 and under some
     networking software. Under DOS versions 3.0 and higher, you may
     need to use the SHARE program provided with DOS to enable file
     sharing. Check documentation for your networking software and DOS
     SHARE program for details.
 
     Return Value
 
     The locking function returns 0 if it is successful. A return value
     of -1 indicates failure, and errno is set to EACCES, EBADF,
     EDEADLOCK, or EINVAL.
                                    -♦-