Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:docs:fapi:dosduphandle [2018/08/26 14:39] – created prokushev | en:docs:fapi:dosduphandle [2021/12/05 09:55] (current) – prokushev | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{logos:os2.gif? | + | {{page>en:templates:fapiint}} |
====== DosDupHandle ====== | ====== DosDupHandle ====== | ||
This call returns a new file handle for an open file, which refers to the same position in the file as the old file handle. | This call returns a new file handle for an open file, which refers to the same position in the file as the old file handle. | ||
- | ==Syntax== | + | ===== Syntax ===== |
- | | + | |
- | ==Parameters== | + | <code c> |
- | ;OldFileHandle | + | DosDupHandle (OldFileHandle, NewFileHandle) |
- | ;NewFileHandle | + | </code> |
- | :FFFFH - Allocate a new file handle and return it here. | + | |
- | :<>FFFFH - Assign this value as the new file handle. A valid value is any of the handles assigned to standard I/O, or the handle of a file currently opened by the process. | + | |
- | :On output, a value of FFFFH returns a value for NewFileHandle, | + | |
- | ==Return Code== | + | ===== Parameters ===== |
- | rc (USHORT) - return | + | |
+ | |||
+ | *OldFileHandle ([[HFILE]]) - input : Current file handle. | ||
+ | *NewFileHandle ([[PHFILE]]) - input/ | ||
+ | *FFFFH - Allocate a new file handle and return it here. | ||
+ | *<> | ||
+ | *On output, a value of FFFFH returns a value for NewFileHandle, | ||
+ | |||
+ | ===== Return Code ===== | ||
+ | |||
+ | rc ([[USHORT]]) - return | ||
+ | | ||
Return code descriptions are: | Return code descriptions are: | ||
- | * 0 NO_ERROR | ||
- | * 4 ERROR_TOO_MANY_OPEN_FILES | ||
- | * 6 ERROR_INVALID_HANDLE | ||
- | * 114 ERROR_INVALID_TARGET_HANDLE | ||
- | ==Remarks== | + | * 0 NO_ERROR |
- | Duplicating the handle duplicates and ties all handle-specific information between OldFileHandle and NewFileHandle. For example, if you move the read/write pointer of either handle by a DosRead, DosWrite, or DosChgFilePtr function call, the pointer for the other handle is also changed. | + | * 4 ERROR_TOO_MANY_OPEN_FILES |
+ | * 6 ERROR_INVALID_HANDLE | ||
+ | * 114 ERROR_INVALID_TARGET_HANDLE | ||
- | The valid values for NewFileHandle include the following handles for standard I/O, which are always available to the process: | + | ===== Remarks ===== |
- | : | + | |
- | : | + | |
- | : | + | |
- | If a file handle value of a currently open file is specified in NewFileHandle, | ||
- | Issuing a DosClose against a file handle | + | Duplicating the handle |
- | ==Example Code== | + | The valid values for NewFileHandle include the following handles for standard I/O, which are always available to the process: |
- | ===C Binding=== | + | |
- | < | + | |
- | #define INCL_DOSFILEMGR | + | |
- | USHORT | + | *0000H |
+ | *0001H | ||
+ | *0002H | ||
- | HFILE OldFileHandle; | + | If a file handle |
- | PHFILE | + | |
- | USHORT | + | Issuing |
- | </ | + | |
- | This example opens a file, creates | + | |
- | < | + | ===== Example Code ===== |
- | #define INCL_DOSFILEMGR | + | |
- | #define OPEN_FILE 0x01 | + | ==== C Binding ==== |
- | #define CREATE_FILE 0x10 | + | |
- | #define FILE_ARCHIVE 0x20 | + | |
- | #define FILE_EXISTS OPEN_FILE | + | |
- | #define FILE_NOEXISTS CREATE_FILE | + | |
- | #define DASD_FLAG 0 | + | |
- | #define INHERIT 0x80 | + | |
- | #define WRITE_THRU 0 | + | |
- | #define FAIL_FLAG 0 | + | |
- | #define SHARE_FLAG 0x10 | + | |
- | #define ACCESS_FLAG 0x02 | + | |
- | #define FILE_NAME " | + | <code c> |
- | # | + | # |
- | #define FILE_ATTRIBUTE FILE_ARCHIVE | + | |
- | #define RESERVED 0L | + | |
+ | |||
+ | HFILE OldFileHandle; | ||
+ | PHFILE | ||
+ | |||
+ | USHORT | ||
+ | </ | ||
- | HFILE | + | This example opens a file, creates a second file handle, then closes the file with the second handle. |
- | HFILE | + | |
- | USHORT | + | |
- | USHORT | + | |
- | PSZ | + | |
- | USHORT | + | |
+ | <code c> | ||
+ | #define INCL_DOSFILEMGR | ||
+ | | ||
+ | #define OPEN_FILE 0x01 | ||
+ | #define CREATE_FILE 0x10 | ||
+ | #define FILE_ARCHIVE 0x20 | ||
+ | #define FILE_EXISTS OPEN_FILE | ||
+ | #define FILE_NOEXISTS CREATE_FILE | ||
+ | #define DASD_FLAG 0 | ||
+ | #define INHERIT 0x80 | ||
+ | #define WRITE_THRU 0 | ||
+ | #define FAIL_FLAG 0 | ||
+ | #define SHARE_FLAG 0x10 | ||
+ | #define ACCESS_FLAG 0x02 | ||
+ | | ||
+ | #define FILE_NAME " | ||
+ | #define FILE_SIZE 800L | ||
+ | #define FILE_ATTRIBUTE FILE_ARCHIVE | ||
+ | #define RESERVED 0L | ||
+ | | ||
+ | HFILE | ||
+ | HFILE | ||
+ | USHORT | ||
+ | USHORT | ||
+ | PSZ | ||
+ | USHORT | ||
+ | | ||
| | ||
| | ||
Line 90: | Line 105: | ||
rc = DosDupHandle(FileHandle, | rc = DosDupHandle(FileHandle, | ||
& | & | ||
- | </ | ||
- | ===MASM Binding=== | + | </ |
- | < | + | |
- | EXTRN DosDupHandle: | + | ==== MASM Binding ==== |
- | INCL_DOSFILEMGR | + | |
- | PUSH | ||
- | PUSH@ WORD NewFileHandle ;New file handle (returned) | ||
- | CALL | ||
+ | EXTRN DosDupHandle: | ||
+ | INCL_DOSFILEMGR | ||
+ | | ||
+ | PUSH | ||
+ | PUSH@ WORD NewFileHandle ;New file handle (returned) | ||
+ | CALL | ||
+ | | ||
Returns WORD | Returns WORD | ||
- | </ | ||
+ | ===== Note ===== | ||
- | ====== Note ====== | ||
Text based on [[http:// | Text based on [[http:// |