PRB: Accessing Remote Files on Windows 95, Windows 98, or Windows Millennium Edition Requires Locking (165966)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows 95
    • the operating system: Microsoft Windows 98
    • the operating system: Microsoft Windows Millennium Edition

This article was previously published under Q165966

SYMPTOMS

Win32 applications on two different computers that run Windows 95, Windows 98, or Windows Millennium Edition open a remote file for reading and writing. One writes data to the file, but the other does not see the newly written data.

CAUSE

The Microsoft Client for Microsoft Networks and the Microsoft Client for NetWare Networks that are included with the cache in Windows 95, Windows 98, and Windows Millennium Edition both read and write to remote files unless the files are locked. Because the Windows client computer may contain cached data that has not been synchronized with the server, applications that run on the client may not see the file as it actually exists on the server.

STATUS

This behavior is by design. The reason for this behavior is to reduce network traffic, thereby improving network performance.

MORE INFORMATION

Win32 applications that run on Windows 95, Windows 98, and Windows Millennium Edition and that share remote files with clients on other computers must lock the regions that they read or write. When a Win32 application locks the file that it is accessing, the Windows network client does not cache reads or writes to the locked region. Therefore, the Win32 application will see the contents of the file as it exists on the server, and writes new data directly to the file on the server.

Generally, locking remote files that can be shared is good procedure because it prevents the file's contents from becoming corrupted when applications that run on multiple computers access the file simultaneously.

To lock a remote file, Win32 applications should use the LockFile function if they open the file with CreateFile or OpenFile. If an application uses a runtime library for opening the file, it should lock the file with the appropriate runtime library functions. For example, an application that uses the Microsoft Visual C++ runtime library _open() function should use the corresponding _locking() function to lock a region of the file.

Modification Type:MinorLast Reviewed:9/27/2004
Keywords:kbAPI kbKernBase kbprb kbProgramming KB165966