How to Request an Opportunistic Lock
Client applications directly request opportunistic locks only when the lock is intended for a file on the local server. When accessing files on remote servers, it is the network redirector, and not the client application, that requests the opportunistic lock from the remote server.
Opportunistic locks are requested by first opening 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 control code 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.