Skip to content

Latest commit

 

History

History
181 lines (132 loc) · 4.68 KB

nf-fileapi-unlockfile.md

File metadata and controls

181 lines (132 loc) · 4.68 KB
UIDtitledescriptionhelpviewer_keywordsold-locationtech.rootms.assetidms.datems.keywordsreq.headerreq.include-headerreq.target-typereq.target-min-winverclntreq.target-min-winversvrreq.kmdf-verreq.umdf-verreq.ddi-compliancereq.unicode-ansireq.idlreq.max-supportreq.namespacereq.assemblyreq.type-libraryreq.libreq.dllreq.irqltargetosreq.typenamesreq.redistms.customf1_keywordsdev_langstopic_typeapi_typeapi_locationapi_name
NF:fileapi.UnlockFile
UnlockFile function (fileapi.h)
Unlocks a region in an open file.
UnlockFile
UnlockFile function [Files]
_win32_unlockfile
base.unlockfile
fileapi/UnlockFile
fs.unlockfile
winbase/UnlockFile
fs\unlockfile.htm
fs
6a930f83-3918-4688-ac60-d1de6857f479
12/05/2018
UnlockFile, UnlockFile function [Files], _win32_unlockfile, base.unlockfile, fileapi/UnlockFile, fs.unlockfile, winbase/UnlockFile
fileapi.h
Windows.h
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Kernel32.lib
Kernel32.dll
Windows
19H1
UnlockFile
fileapi/UnlockFile
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-File-l1-1-0.dll
KernelBase.dll
API-MS-Win-Core-File-l1-2-0.dll
API-MS-Win-Core-File-l1-2-1.dll
API-MS-Win-Core-File-l1-2-2.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
UnlockFile

UnlockFile function

-description

Unlocks a region in an open file. Unlocking a region enables other processes to access the region.

For an alternate way to specify the region, use the UnlockFileEx function.

-parameters

-param hFile [in]

A handle to the file that contains a region locked with LockFile. The file handle must have been created with either the GENERIC_READ or GENERIC_WRITE access right. For more information, see File Security and Access Rights.

-param dwFileOffsetLow [in]

The low-order word of the starting byte offset in the file where the locked region begins.

-param dwFileOffsetHigh [in]

The high-order word of the starting byte offset in the file where the locked region begins.

-param nNumberOfBytesToUnlockLow [in]

The low-order word of the length of the byte range to be unlocked.

-param nNumberOfBytesToUnlockHigh [in]

The high-order word of the length of the byte range to be unlocked.

-returns

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

-remarks

This function always operates synchronously, but may not queue a completion entry when a completion port is associated with the file handle.

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 operating system. However, the time it takes for the operating system to unlock these locks depends upon available system resources. Therefore, it is recommended that your process explicitly unlock all files it has locked when it terminates. If this is not done, access to these files may be denied if the operating system has not yet unlocked them.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

TechnologySupported
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

-see-also

Locking and Unlocking Byte Ranges in Files

CreateFile

File Management Functions

LockFile

UnlockFileEx

close