How make FILE* from HANDLE in WinApi?(如何从 WinApi 中的 HANDLE 制作 FILE*?)
问题描述
是否有简单的方法可以从指向管道一端的 WinApi HANDLE 创建 FILE*?类似于我们在 unix 中所做的:fdopen(fd,
Is there easy way to create FILE* from WinApi HANDLE which points to one end of pipe?
Something like we do in unix: fdopen(fd,<mode>);
推荐答案
您可以这样做,但必须分两步完成.首先,调用_open_osfhandle()代码> 从 Win32 HANDLE 值获取 C 运行时文件描述符,然后调用
_fdopen()
从文件描述符中获取一个 FILE*
对象.
You can do this but you have to do it in two steps. First, call _open_osfhandle()
to get a C run-time file descriptor from a Win32 HANDLE value, then call _fdopen()
to get a FILE*
object from the file descriptor.
这篇关于如何从 WinApi 中的 HANDLE 制作 FILE*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 WinApi 中的 HANDLE 制作 FILE*?


- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- C++ 协变模板 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 从python回调到c++的选项 2022-11-16