From: alladyn on
Hello, I just found out that file is not locked if I use that file
attributes FILE_SHARE_READ and FILE_SHARE_WRITE. Does it mean that I don't
have to use synchronization mechanizm for reading and writing and system
will take care of that?

thanks

CreateFile(lpszFileName, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);


From: David Lowndes on
>Hello, I just found out that file is not locked if I use that file
>attributes FILE_SHARE_READ and FILE_SHARE_WRITE. Does it mean that I don't
>have to use synchronization mechanizm for reading and writing and system
>will take care of that?

Can you explain what synchronisation you think this facility may
provide you?

While each process will be able to read and write to the file, it's
still up to your processes to behave in a cooperative manner with
regards to the contents of the file.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
From: alladyn on
Actually I found out too, that when moving File Poniter
I have to use synchronization, system doesn't help here.
But when just reading no need to.
thanks

"David Lowndes" <davidl(a)example.invalid> wrote in message
news:9cl5h11at51h6qhv4bl6tanjv2measjkbi(a)4ax.com...
> >Hello, I just found out that file is not locked if I use that file
>>attributes FILE_SHARE_READ and FILE_SHARE_WRITE. Does it mean that I
>>don't
>>have to use synchronization mechanizm for reading and writing and system
>>will take care of that?
>
> Can you explain what synchronisation you think this facility may
> provide you?
>
> While each process will be able to read and write to the file, it's
> still up to your processes to behave in a cooperative manner with
> regards to the contents of the file.
>
> Dave
> --
> MVP VC++ FAQ: http://www.mvps.org/vcfaq