Stephan Szabo wrote: > On Fri, 20 Sep 2002, Mike Mascari wrote: >> >>Yes! Indeed that does work. > > > Thinking back, I think that may still fail on Win95 (using MoveFile). > Once in the past I had to work on (un)installers for Win* and I > vaguely remember Win95 being more strict than Win98 but that may just > have been with moving the executable you're currently running.
Well, here's the test: foo.txt contains "This is FOO!" bar.txt contains "This is BAR!" Process 1 opens foo.txt Process 2 opens foo.txt Process 1 sleeps 7.5 seconds Process 2 sleeps 15 seconds Process 1 uses MoveFile() to rename "foo.txt" to "foo2.txt" Process 1 uses MoveFile() to rename "bar.txt" to "foo.txt" Process 1 uses DeleteFile() to remove "foo2.txt" Process 2 awakens and displays "This is FOO!" On the filesystem, we then have: foo.txt containing "This is BAR!" The good news is that this works fine under NT 4 using just MoveFile(). The bad news is that it requires the files be opened using CreateFile() with the FILE_SHARE_DELETE flag set. The C library which ships with Visual C++ 6 ultimately calls CreateFile() via fopen() but with no opportunity through the standard C library routines to use the FILE_SHARE_DELETE flag. And the FILE_SHARE_DELETE flag cannot be used under Windows 95/98 (Bad Parameter). Which means, on those platforms, there still doesn't appear to be a solution. Under NT/XP/2K, AllocateFile() will have to modified to call CreateFile() instead of fopen(). I'm not sure about ME, but I suspect it behaves similarly to 95/98. Mike Mascari [EMAIL PROTECTED] ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]