Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DosQHandType (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_DOSFILEMGR
USHORT DosQHandType(hf, pfsType, pusDeviceAttr)
HFILE hf; /* file handle */
PUSHORT pfsType; /* pointer to variable for handle type */
PUSHORT pusDeviceAttr; /* pointer to variable for device attribute */
The DosQHandType function retrieves information that specifies whether the
given file handle identifies a file, device, or pipe.
Parameter Description
────────────────────────────────────────────────────────────────────────────
hf Identifies the file. This handle must have been created
previously by using the DosOpen function.
pfsType Specifies the type of file or device associated with the file
handle. It can be one of the following:
Value Meaning
─────────────────────────────────────────────────────────────
HANDTYPE_DEVICE The handle is to a device, such as a
printer.
HANDTYPE_FILE The handle is to a file.
HANDTYPE_PIPE The handle is to a pipe.
If the file or device is located on a network, this parameter
is a combination of one of the values given above and the
value HANDTYPE_NETWORK (0x8000).
pusDeviceAttr Points to the variable that receives the device-driver
attribute word.
Return Value
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be the following:
ERROR_INVALID_HANDLE
Comments
The DosQHandType function allows some interactive or file-oriented programs
to determine the source of their input. For example, the cmd.exe program
suppresses the system prompt if the input is from a disk file.
Example
This example calls the DosQHandType function to determine if standard output
has been redirected to a file. The LOBYTE macro is an important part of this
example; it allows the handle type to be determined even if the handle is to
a file or device on a network:
USHORT fsType, usDeviceAttr;
DosQHandType(1, /* file handle */
&fsType, /* type of handle */
&usDeviceAttr); /* device attribute */
if (LOBYTE(fsType) == HANDTYPE_DEVICE)
VioWrtTTY("stdout is a device\r\n", 20, 0);
else if (LOBYTE(fsType) & HANDTYPE_FILE) {
if (fsType & HANDTYPE_NETWORK)
VioWrtTTY("stdout is a networked file\r\n", 28, 0);
else
VioWrtTTY("stdout is a local file\r\n", 24, 0);
}
See Also
DosOpen, DosQFHandState
♦