Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- DOS 5.0 Ref. - <b>function 5ch lock/unlock file dos 3.1+</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function 5Ch            Lock/Unlock File                             DOS 3.1+

    Denies or allows access to the specified region in a file.

        Entry   AH = 5Ch
                AL    = 0 | 1   Lock | unlock a file
                BX    = File handle
                CX:DX = File offset of region
                SI:DI = Length of region

        Return  Nothing
                or
                AX = Error code, if CF is set
                     | 01h Invalid function code
                     | 06h Invalid handle
                     | 21h Lock violation
                     | 24h Sharing buffer overflow

    ------------------------------------------------------------------

    This function is used to lock or unlock a selected portion of a
    file, preventing or allowing access to that region by other
    processes in a multitasking or networking environment.


    File sharing must be loaded (by running the SHARE program) before
    this function can be used on a local computer.

    This function returns an error value of 21h (lock violation) if
    all or part of the specified region is already locked or if the
    specified region is not identical to a region previously locked by
    the same procedure.

    If another program attempts to write to or read from a locked
    region, DOS retries the operation one or more times; if all
    retries fail, DOS issues an interrupt 24h for the requesting
    program. A program can set the number of retries by using function
    440bh.

    The locked region can be anywhere in a file. For example, locking
    beyond the end of the file is not an error. Functions 45h (DUP)
    and 46h (FORCEDUP) duplicate access to any locked regions. Passing
    an open file to a child program by using function 4b00h (EXEC)
    does not duplicate access to locked regions.

    Programs should not depend on being denied access to a locked
    region. To determine the status of a region (locked or unlocked),
    a program can attempt to lock the region and then examine the
    error value.


    Note
    File locks should be released before terminating a program.

    Use this function in the following file modes:
                Deny read sharing mode
                Deny none sharing mode
                Deny write sharing mode, and file opened for read/write
                Deny write sharing mode, and file opened for write only

See Also: 440bh 45h 46h 4b00h Int 24h 3dh 3eh 59h 1000h

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