Microsoft KB Archive/195606

{|
 * width="100%"|

PRB: Opening a File Twice with Compatible Sharing Modes Fails

 * }

Q195606

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51, 4.0
 * Microsoft Windows 95
 * Microsoft Windows 98
 * the operating system: Microsoft Windows 2000

-

SYMPTOMS
When one or more processes try to open the same file more than once with compatible access and sharing modes at nearly the same time, sometimes the second attempt to open the file fails with error 32 (ERROR_SHARING_VIOLATION).

CAUSE
This behavior can be caused by applications that are running that intercept calls to open a file to do their own processing first. These applications can open the file in an incompatible mode, causing subsequent attempts to open the file to fail with a sharing violation. A typical example of this type of application is a virus scanner.

RESOLUTION
To open the file without the error, do one of the following:


 * Try to open the file again. This attempt to open the file should succeed after the application is finished processing.
 * Disable the option in the application that checks files when they are opened.

MORE INFORMATION
If an application, such as a virus scanner, is set up to check files when they are opened, the application might hold the file open in an incompatible mode while processing the file, causing other applications to receive sharing violations when attempting to open the file.

Additional query words:

Keywords : kbAPI kbFileIO kbKernBase kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbOSWin95 kbOSWin98 kbDSupport kbGrpDSKernBase

Issue type : kbprb

Technology : kbAudDeveloper kbWin32sSearch kbWin32API