Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
en:docs:fapi:dosduphandle [2018/08/26 14:39] – created prokushev | en:docs:fapi:dosduphandle [2018/09/02 04:59] – prokushev | ||
---|---|---|---|
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
- | | + | |
+ | | ||
==Parameters== | ==Parameters== | ||
- | ;OldFileHandle (HFILE) - input : Current file handle. | + | |
- | ;NewFileHandle (PHFILE) - input/ | + | *OldFileHandle (HFILE) - input : Current file handle. |
- | :FFFFH - Allocate a new file handle and return it here. | + | *NewFileHandle (PHFILE) - input/ |
- | :<> | + | *FFFFH - Allocate a new file handle and return it here. |
- | :On output, a value of FFFFH returns a value for NewFileHandle, | + | *<> |
+ | *On output, a value of FFFFH returns a value for NewFileHandle, | ||
==Return Code== | ==Return Code== | ||
- | rc (USHORT) - return | + | |
+ | rc (USHORT) - return | ||
+ | | ||
Return code descriptions are: | Return code descriptions are: | ||
- | * 0 NO_ERROR | + | |
- | * 4 ERROR_TOO_MANY_OPEN_FILES | + | |
- | * 6 ERROR_INVALID_HANDLE | + | * 4 ERROR_TOO_MANY_OPEN_FILES |
- | * 114 ERROR_INVALID_TARGET_HANDLE | + | * 6 ERROR_INVALID_HANDLE |
+ | * 114 ERROR_INVALID_TARGET_HANDLE | ||
==Remarks== | ==Remarks== | ||
+ | |||
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. | 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. | ||
The valid values for NewFileHandle include the following handles for standard I/O, which are always available to the process: | The valid values for NewFileHandle include the following handles for standard I/O, which are always available to the process: | ||
- | :0000H Standard input | + | |
- | :0001H Standard output | + | *0000H Standard input |
- | :0002H Standard error. | + | *0001H Standard output |
+ | *0002H Standard error. | ||
If a file handle value of a currently open file is specified in NewFileHandle, | If a file handle value of a currently open file is specified in NewFileHandle, | ||
Line 36: | Line 43: | ||
==Example Code== | ==Example Code== | ||
===C Binding=== | ===C Binding=== | ||
- | <PRE> | ||
- | #define INCL_DOSFILEMGR | ||
- | USHORT | + | #define INCL_DOSFILEMGR |
+ | |||
+ | | ||
+ | |||
+ | HFILE OldFileHandle; | ||
+ | PHFILE | ||
+ | |||
+ | USHORT | ||
- | HFILE OldFileHandle; | ||
- | PHFILE | ||
- | |||
- | USHORT | ||
- | </ | ||
This example opens a file, creates a second file handle, then closes the file with the second handle. | This example opens a file, creates a second file handle, then closes the file with the second handle. | ||
- | < | + | |
- | #define INCL_DOSFILEMGR | + | |
- | + | #define OPEN_FILE 0x01 | |
- | #define OPEN_FILE 0x01 | + | #define CREATE_FILE 0x10 |
- | #define CREATE_FILE 0x10 | + | #define FILE_ARCHIVE 0x20 |
- | #define FILE_ARCHIVE 0x20 | + | #define FILE_EXISTS OPEN_FILE |
- | #define FILE_EXISTS OPEN_FILE | + | #define FILE_NOEXISTS CREATE_FILE |
- | #define FILE_NOEXISTS CREATE_FILE | + | #define DASD_FLAG 0 |
- | #define DASD_FLAG 0 | + | #define INHERIT 0x80 |
- | #define INHERIT 0x80 | + | #define WRITE_THRU 0 |
- | #define WRITE_THRU 0 | + | #define FAIL_FLAG 0 |
- | #define FAIL_FLAG 0 | + | #define SHARE_FLAG 0x10 |
- | #define SHARE_FLAG 0x10 | + | #define ACCESS_FLAG 0x02 |
- | #define ACCESS_FLAG 0x02 | + | |
- | + | #define FILE_NAME " | |
- | #define FILE_NAME " | + | #define FILE_SIZE 800L |
- | #define FILE_SIZE 800L | + | #define FILE_ATTRIBUTE FILE_ARCHIVE |
- | #define FILE_ATTRIBUTE FILE_ARCHIVE | + | #define RESERVED 0L |
- | #define RESERVED 0L | + | |
- | + | HFILE | |
- | HFILE | + | HFILE |
- | HFILE | + | USHORT |
- | USHORT | + | USHORT |
- | USHORT | + | PSZ |
- | PSZ | + | USHORT |
- | USHORT | + | |
| | ||
| | ||
Line 90: | Line 96: | ||
rc = DosDupHandle(FileHandle, | rc = DosDupHandle(FileHandle, | ||
& | & | ||
- | </ | ||
===MASM Binding=== | ===MASM Binding=== | ||
- | <PRE> | ||
- | EXTRN DosDupHandle: | ||
- | 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 ====== |