www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/04/08:30:12

From: Robert Hoehne <Robert DOT Hoehne AT Mathematik DOT tu-chemnitz DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP: cannot read file while opened in word!?!
Date: Fri, 04 Apr 1997 10:30:25 +0200
Organization: TU Chemnitz-Zwickau
Lines: 47
Message-ID: <3344BC20.56EC@Mathematik.tu-chemnitz.de>
References: <33429627 DOT 50B1 AT ife DOT ee DOT ethz DOT ch>
NNTP-Posting-Host: errno.hrz.tu-chemnitz.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Bernhard Baeumle wrote:
> 

> ===> From my djgpp-program I cannot even open this
> file for reading (as long as it's opened with Word).
> Note: fopen("test.txt", "r") returns NULL   !?!?!?

I'm woking currently on a program written in DJGPP
which should run later also in a network, and so
I had the same problem (accessing a file from
multiple programs). I think I have solved it and
I will describe it (I have not the correct code here).

At first it is required, that Word uses the file
with the correct sharing flags set. (under W95
you don't need to load share.exe). And from the
DJGPP program (your program) you have to open the
file with the _dos_open() (I don't know if it possible also
with fopen) function and give there explicit the
sharing flags for opening the file (these are
the SH_... constants from fcntl.h). Please read
the doc about that function for more details.

At least for me it worked, when I had my program running
in two DOS-boxes and one of them opened the file for
read/write and the other only for read.

And again. This will work only if Word opens the
file in the correct mode and has not locked it.

> Of course I heard of things like "file-locking" but at
> least I would like to READ a file that is opened with
> Word or any other application.
But if Word has locked that file you will also not
able to simply read it.

> - is there a option in Word for Windows95 or
Look in the doc or an other news group.

Robert
-- 
*****************************************************************
* Robert Hoehne, Fakultaet fuer Mathematik, TU-Chemnitz-Zwickau *
* Post:    Am Berg 3, D-09573 Dittmannsdorf                     *
* e-Mail:  Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE              *
* WWW:     http://www.tu-chemnitz.de/~rho                       *
*****************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019