2.9. File Locking

When we discussed theCreateFile function in Section 2.7, you saw that its third parameter controls the accessibility of an open file to other processes. For example, if you specify FILE_SHARE_READ when you open a file with CreateFile, then other processes can open the file for read access but not for write access. You can also open a file so that no other process can access it at all, by passing a zero in for the share mode.

While this file-wide access control scheme is appropriate in many cases, there are many others where it is simply too general. For example, you may have a file of structures available on a server. It might contain employee records, and there may be many users on the network who need to simultaneously access ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.