Is it possible to get the underlying file HANDLE from a std::ofstream (Visual C++ 2005)?
This is the opposite of this question:
Can I use CreateFile, but for
The C++ standard does not provide any means for specifying or retrieving the raw file descriptors of an ofstream
, so I don't believe this is possible. What is possible, though, would be to build a custom streambuf
class that implements stream buffering to and from a HANDLE
, then to define a custom ostream
type that uses that buffer. I'm not sure if that's really what you're looking for, but it is a viable option.