A version of this page is also available for
This function unlocks a region in an open file. Unlocking a region enables other processes to access the region.
BOOL UnlockFileEx( HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped );
[in] Handle to a file that contains a region locked by the LockFileEx function. The file handle must have been created with the GENERIC_READ or GENERIC_WRITE access right.
Reserved. Set to zero.
[in] Low-order portion of the length of the byte range to unlock.
[in] High-order portion of the length of the byte range to unlock.
[in] Pointer to an OVERLAPPED structure that is used with the unlock request. This structure contains the file offset of the beginning of the unlock range.
Nonzero indicates success. Zero indicates failure. For extended error information, call GetLastError.
Unlocking a region of a file releases a previously acquired lock on the file. The region to unlock must correspond exactly to an existing locked region. Two adjacent regions of a file cannot be locked separately and then unlocked using a single region that spans both locked regions.
If a process terminates with a portion of a file locked or closes a file that has outstanding locks, the locks are unlocked by the OS. However, the time it takes for the OS to unlock these locks depends upon available system resources. Therefore, explicitly unlock all locked files when a process ends. Otherwise, access to these files can be denied if the OS has not yet unlocked them.
|Windows Embedded CE||Windows CE 5.0 and later|
|Windows Mobile||Windows Mobile Version 5.0 and later|