Win平臺,文件句柄類型的相互轉換
已知:
CreateFile返回的是HANDLE,
fopen返回的是FILE *,
_open返回的是個int,
轉換:
1、FILE * => int
Gets the file descriptor associated with a stream.
int _fileno( FILE *stream );
2、int => HANDLE
Returns operating-system file handle associated with existing low-level file descriptor.
long _get_osfhandle( int fd );
3、HANDLE => int
Associates a C run-time file descriptor with an existing operating-system file handle.
int _open_osfhandle (
intptr_t osfhandle,
int flags
);4、FILE * => int
應該就是FILE結構中的_file字段。

