Anyway to do conversion between FILE and CFile object?
Printable View
Anyway to do conversion between FILE and CFile object?
CFile is a MFC class meanwhile FILE is a data type of ANSI C.
Yes. and any way to convert an CFile object to FILE stream?
(Or let a FILE stream pointer point to CFile object and get the correct result?)
FILE* to CFile
CFile to FILE*Code:FILE* f = fopen(path, szMode);
int handle = f->_file;
HANDLE hFile = (HANDLE) _get_osfhandle(handle);
CFile cf(hFile);
Code:CFile cf;
cf.Open(...);
HANDLE hFile = cf;
int handle = _open_osfhandle((LONG)hFile, _mode);
FILE* f = fdopen(handle, szMode);