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 31h keep program</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function 31h            Keep Program

    Ends the current program by returning control to its parent
    program but leaves (keeps) the program in memory and preserves the
    program's resources, such as open files and allocated memory.

        Entry   AH = 31h
                AL = Return value
                DX = Size of resident portion, in paragraphs

        Return  This function does not return

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

    The return value may be retrieved by a parent process via function
    4Dh, or tested by means of the errorlevel feature of DOS batch
    processing. If the program terminates normally, the return value
    should be 00h.


    Function 31h carries out the following actions:

    - Reallocates program memory to the amount specified by DX (min.
      6 paragraphs). Program memory includes only the program segment
      prefix (PSP) and program data and code. The reallocation does
      not affect the program's environment block, nor does it affect
      the memory allocated by the program after it was loaded.
    - Flushes the file buffers but leaves files open. Any locked
      regions in the open files remain locked.
    - Restores interrupt 22h, 23h, and 24h vectors from the addresses
      saved in the PSP.
    - Transfers control to the address specified by offset 0Ah
      (termination address) in the PSP.

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

    Before calling Keep Program, the initialization routine of a
    terminate-but-stay-resident (TSR) program should do the following:

        - Close all unneeded files, including standard devices
        - Free the environment block if it is not needed
        - Free all memory not needed to support interrupt handlers

See Also: 4dh 4ch 4b00h Int 2Fh StdDevices PSP

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