|
-
March 30th, 1999, 04:05 AM
#1
share file
Hi
I want to open file, but if this file is opened by other user, I'll open in read opnly
This is my code, but doens't work ..
HANDLE hdl ;
hdl = CreateFile ( FileName, GENERIC_READ | GENERIC_WRITE , FILE_SHARE_READ ,
NULL,OPEN_EXISTING ,FILE_ATTRIBUTE_NORMAL , NULL );
if ( hdl == INVALID_HANDLE_VALUE )
hdl = CreateFile ( FileName, GENERIC_READ ,0,NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL , NULL );
Thanks for Help
-
March 30th, 1999, 06:44 AM
#2
Re: share file
Your second CreateFile call is using a dwShareMode of 0 instead of FILE_SHARE_READ. If dwShareMode is 0, the file cannot be shared, so the call will always fail.
Bear in mind also that the other user may not have opened the file in shared mode.
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|