Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I create a file in binary or text mode with win32 CreateFile()

1,115 views
Skip to first unread message

dann_...@my-deja.com

unread,
Jun 8, 1999, 3:00:00 AM6/8/99
to
Hi,

I would like to know how can I write a file in
binary mode with win32 API CreateFile, WriteFile.

I'm using these API 'cause I'm reading and
writing with my own buffer by using the
FILE_FLAG_NO_BUFFERING flag.

I search and I can't find nothing that permits me
to change the mode (binary or text)

Can someone help please...

Thank in advance.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

floyd rogers

unread,
Jun 8, 1999, 3:00:00 AM6/8/99
to
dann_...@my-deja.com wrote in article <7jiqf7$h8k$1...@nnrp1.deja.com>...

> I would like to know how can I write a file in
> binary mode with win32 API CreateFile, WriteFile.
>
> I'm using these API 'cause I'm reading and
> writing with my own buffer by using the
> FILE_FLAG_NO_BUFFERING flag.
>
> I search and I can't find nothing that permits me
> to change the mode (binary or text)

Binary and Text mode are high-level concepts connected to the C and C++
standard, and have nothing to do with the native Win32 file system calls.
CreateFile[A|W] and WriteFile must be considered a pure binary-mode
call - they do no processing of the data in the Read/Write buffers, unlike
the _fopen/_fread/_fwrite C-runtime calls.

Floyd Rogers

Alan Greasley

unread,
Jun 9, 1999, 3:00:00 AM6/9/99
to
It will be in binary mode unless you apply

HANDLE fh = CreateFile( ...)

_osfile(fh) |= FTEXT;

as the Microsoft C Runtime does ...


dann_...@my-deja.com wrote in message <7jiqf7$h8k$1...@nnrp1.deja.com>...
>Hi,


>
>I would like to know how can I write a file in
>binary mode with win32 API CreateFile, WriteFile.
>
>I'm using these API 'cause I'm reading and
>writing with my own buffer by using the
>FILE_FLAG_NO_BUFFERING flag.
>
>I search and I can't find nothing that permits me
>to change the mode (binary or text)
>

Ted Miller

unread,
Jun 9, 1999, 3:00:00 AM6/9/99
to
Huh?

Binary/text mode is purely a C runtime concept. There is no counterpart in
the win32 APIs. All I/O to files done with WriteFile is the equivalent of
"binary" mode -- ie, what you pass in is what gets written, verbatim.

Alan Greasley <agre...@adc.metrica.co.uk> wrote in message
news:928924477.5033.0...@news.demon.co.uk...

0 new messages