Platform SDK: Files and I/O

Typical Use

The typical way to use opportunistic locks is first to open a file with permissions and flags appropriate to the application opening the file. All files for which opportunistic locks will be requested must be opened for overlapped (asynchronous) operation. After the files are opened for overlapped operation, use the DeviceIoControl function with the appropriate operation to request an opportunistic lock. For a list of the opportunistic lock operations, see Opportunistic Lock Operations.

Applications are notified that an opportunistic lock is broken by using the hEvent member of the OVERLAPPED structure associated with the file. Applications may also use functions such as GetOverlappedResult and HasOverlappedIoCompleted. The application is responsible for associating the correct file with the broken opportunistic lock.

For more information on notification, see Synchronization.