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字段。

posted on 2008-10-31 15:26 FongLuo 阅读(813) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

常用链接

留言簿

随笔分类(11)

随笔档案(79)

文章档案(1)

收藏夹(38)

学习网站

一般网站

最新随笔

搜索

积分与排名

最新评论

阅读排行榜