I can use CFile to get member m_hFile,how to get the CFile's file descriptor(like File*)?I need to convert file handle to file pointer. Thanks!
Asked
Active
Viewed 459 times
0
-
The dup wasn't mfc specific, but the same principle applies. Just use [_fdopen](https://msdn.microsoft.com/en-us/library/dye30d82.aspx). – StoryTeller - Unslander Monica Jan 03 '18 at 08:07
-
2Sounds like an [XY Problem](http://xyproblem.info). What are you really trying to accomplish? – IInspectable Jan 03 '18 at 10:05
1 Answers
2
To my knowledge CFile doesn't use the FILE * abstraction (it uses the windows ReadFile/WriteFile APIs), however you can use _fdopen to get a FILE * from a file descriptor and _open_osfhandl to get a file descriptor for a HANDLE.
You can also use CStdioFile to use FILE * based file operations.

SoronelHaetir
- 14,104
- 1
- 12
- 23