fcntl() is not on Windows that I know of.  There is a GetFileInformationByHandle() call which may suffice.  I am inclined to not save openmode and go back to just getting the open mode in the *nix close() when flushing is enabled ?