GetFileType
GetFileType is a Windows API function used to determine the type of a file handle. It helps programs decide how to handle a given handle without opening or inspecting the underlying object directly.
The function is declared as DWORD GetFileType(HANDLE hFile). The hFile parameter must be a valid handle, typically
GetFileType returns one of several FILE_TYPE constants:
- FILE_TYPE_DISK for disk files
- FILE_TYPE_CHAR for character devices (such as consoles or serial ports)
- FILE_TYPE_PIPE for named pipes
- FILE_TYPE_UNKNOWN if the type cannot be determined or the handle is invalid
If the return value is FILE_TYPE_UNKNOWN, GetLastError may provide more information about the failure.
GetFileType does not determine whether a path refers to a directory or a regular file; it reports
Related APIs include CreateFile (to obtain handles), GetLastError (for error details when GetFileType fails), and the
GetFileType has been part of the Win32 API for many generations of Windows, providing a lightweight
---