[comp.windows.ms] "OpenFile" can it do ASCII mode? "open" can, with constants

burgoyne@eng.umd.edu (John R. Burgoyne) (04/09/90)

     I am trying to use the Windows "OpenFile" command to write
ASCII text to a file. (The references to the "OpenFile" command are
on pgs. 383-4 of the Version 2.0 SDK Programmer's Reference)

     The problem is that "OpenFile" defaults to writing files in
binary mode and there doesn't appear to be any way to write the
file in ASCII text mode. Thus, my CR/LF commands get written
literally, rather than as CR/LFs.

     The standard "open" command from C has constants which can be
used to make the file write in ASCII text mode correctly. However,
the "open" constants seem to be incompatible with the Windows
"OpenFile" command. I have been able to use "open" to successfully
write ASCII text files from my Windows program.

     Of course, I want to use the Windows "OpenFile" command to
conform to Bill G's standards and to make my program able to use
DDE in the future. Does anybody know how to solve the above
problem?

     Any help is greatly appreciated.

jupiter@hpavla.AVO.HP.COM (Shirley Jupiter) (04/11/90)

This is an example of the method I've used to write text files.

hFile = OpenFile ("FILENAME", &OfStruct, OF_CREATE | OF_WRITE);
write (hFile, "string", 6);
buffer[0] = '\r';
buffer[1] = '\n';
write (hFile, buffer, 2);
close (hFile);

--Shirley Jupiter
  Hewlett-Packard Avondale Division
  jupiter@hpavla.AVO.HP.COM