RE: Replicating a Directory - Accessing / coping files locked by another process

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hello Todor Todorov,
It should not be ReadDirectoryChangesW which give you share violation when
a 3rd app is going to copy, but depends on the sharemode you used when
obtaining a handle to the directory.
I am not sure what share mode you used with CreateFile. But from your
description of error which the 3rd app report. you did probably not specify
FILE_SHARE_READ when calling CreateFile to get the handle to the directory.
There are 3 share mode you can use:
FILE_SHARE_READ -- Enables subsequent operations or other process to obtain
read access
FILE_SHARE_WRITE -- Enables subsequent operations or other process to
obtain write access
FILE_SHARE_DELETE -- Enables subsequent operations or other process to
obtain delete access
For more details, please reference dwShareMode in CreateFile doc.

Please let me know if my answer helps you resolve the problem. If there is
anything more I can assist you, please feel free to let me know.

Thanks,
Rhett Gong [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties and confers no rights.

.



Relevant Pages

  • Re: help with crazy problem
    ... Are you using Unicode? ... VS7 to use one of the older debug formats you can run the code under the VS6 debugger. ... Note that CreateFile does not actually exist; There are two real APIs, ... >use API calls somewhat liberally in the app. ...
    (microsoft.public.vc.mfc)
  • Re: DeviceIoControl And CreateFile
    ... documentation, you should use NULL as the last parameter of CreateFile, ... > I'm working out a problem with an app engineer. ... The problem is the app calls DeviceIoControl from many ... > having a single CreateFileat app init and a CloseFile() at app exit. ...
    (microsoft.public.development.device.drivers)
  • Re: DeviceIoControl And CreateFile
    ... thread can send i/o in parallel. ... > I'm working out a problem with an app engineer. ... The problem is the app calls DeviceIoControl from many ... > My concern is that each CreateFile() may be expensive as opposed to just ...
    (microsoft.public.development.device.drivers)
  • Re: shareDenyWrite is not enough
    ... handler and see what the::CreateFile arguments are! ... VC2008) that lets you specify a file path, open mode, and share mode. ... specified a file called c:\x.bat on my PC, Read mode, and shareDenyWrite. ... I then opened another instance of the app and repeated the above. ...
    (microsoft.public.vc.mfc)
  • Re: Replicating a Directory - Accessing / coping files locked by another process
    ... I am not sure it's the ReadDirectoryChangesW that gives the sharing ... party app save a file, our COM+ service will try to copy it. ... we get a file sharing violation. ...
    (microsoft.public.win32.programmer.kernel)