UnlockFileEx function
Unlocks a region in the specified file. This function can operate either synchronously or asynchronously.
Syntax
BOOL WINAPI UnlockFileEx( _In_ HANDLE hFile, _Reserved_ DWORD dwReserved, _In_ DWORD nNumberOfBytesToUnlockLow, _In_ DWORD nNumberOfBytesToUnlockHigh, _Inout_ LPOVERLAPPED lpOverlapped );
Parameters
- hFile [in]
-
A handle to the file. The handle must have been created with either the GENERIC_READ or GENERIC_WRITE access right. For more information, see File Security and Access Rights.
- dwReserved
-
Reserved parameter; must be zero.
- nNumberOfBytesToUnlockLow [in]
-
The low-order part of the length of the byte range to unlock.
- nNumberOfBytesToUnlockHigh [in]
-
The high-order part of the length of the byte range to unlock.
- lpOverlapped [in, out]
-
A pointer to an OVERLAPPED structure that the function uses with the unlocking request. This structure contains the file offset of the beginning of the unlock range. You must initialize the hEvent member to a valid handle or zero. For more information, see Synchronous and Asynchronous I/O.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero or NULL. To get extended error information, call GetLastError.
Remarks
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.
Locks are released before the CloseHandle function is finished processing.
In Windows 8 and Windows Server 2012, this function is supported by the following technologies.
| Technology | Supported |
|---|---|
|
Server Message Block (SMB) 3.0 protocol |
Yes |
|
SMB 3.0 Transparent Failover (TFO) |
Yes |
|
SMB 3.0 with Scale-out File Shares (SO) |
Yes |
|
Cluster Shared Volume File System (CsvFS) |
Yes |
|
Resilient File System (ReFS) |
Yes |
Requirements
|
Minimum supported client |
Windows XP [desktop apps | Windows Store apps] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps | Windows Store apps] |
|
Minimum supported phone |
Windows Phone 8 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- CreateFile
- File Management Functions
- LockFile
- LockFileEx
- OVERLAPPED
- Synchronous and Asynchronous I/O
- UnlockFile