INF: How to Truncate a File

ID Number: Q32800

2.x 3.x 4.x 5.00

MS-DOS

Summary:

The following is a fast algorithm for truncating a file handle using

the MS-DOS file handle services of interrupt 21h:

1. Open the file using interrupt 21h service 03Dh (open file handle).

2. Move the file pointer to the point at which truncation is to occur

using interrupt 21h service 042h (move file handle pointer).

3. Write 0 bytes to the file using interrupt 21h service 040h (write

file handle).

4. Close the file using interrupt 21h service 03Eh (close file handle).