Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  Function 5CH (decimal 92) locks certain parts of a file so that the file
  can be shared by several programs without one program interfering with the
  operations of another. If one program locks one part of a file, it can use
  or change that part of the file while it is locked, safe in the knowledge
  that no other program will be able to use that part while it remains
  locked. As you may guess, file locking is used only in conjunction with
  file-sharing operations, like those that can occur in a network.

  When you call function 5CH, AL indicates whether you are locking (AL =
  00H) or unlocking (AL = 01H) a portion of a file. BX gives the file
  handle. CX and DX are treated as a 4-byte integer that specifies the byte
  offset of the start of the locked portion of the file. SI and DI also form
  a 4-byte integer that specifies the length of the locked portion. The
  first register in each of these register pairs (CX or SI) gives the
  high-order part of the integer. When function 5CH successfully locks a
  portion of a file, it clears the carry flag. If an error occurs, the carry
  flag is set, and AX contains an error code: 01H (invalid function), 06H
  (invalid handle), 21H (file-locking violation), or 24H (sharing buffer
  overflow).

  You are not allowed to unlock file portions piecemeal or in combination;
  an unlock request should exactly match a previous lock request. You must
  also explicitly remove all locks before closing a file or terminating a
  program that does file locking.

  Use function 5CH to lock a file region before you read or write a file
  that may have been locked by another program; use function 5CH again to
  unlock the region after the read or write operation is complete. The first
  call to function 5CH tells you if the part of the file you intend to
  access is already locked; you should not rely on the read and write
  functions to return error codes if they access a previously locked region.

  Function 5CH is supported only in DOS versions 3.0 and later.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson