Share via


UnlockFileEx (Windows Embedded CE 6.0)

1/6/2010

This function unlocks a region in an open file. Unlocking a region enables other processes to access the region.

Syntax

BOOL UnlockFileEx(
  HANDLE hFile, 
  DWORD dwReserved,
  DWORD nNumberOfBytesToLockLow,
  DWORD nNumberOfBytesToLockHigh,
  LPOVERLAPPED lpOverlapped
);

Parameters

  • hFile
    [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.
  • dwReserved
    Reserved. Set to zero.
  • nNumberOfBytesToLockLow
    [in] Low-order portion of the length of the byte range to unlock.
  • nNumberOfBytesToLockHigh
    [in] High-order portion of the length of the byte range to unlock.
  • lpOverlapped
    [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.

Return Value

Nonzero indicates success. Zero indicates failure. For 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.

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.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 5.0 and later

See Also

Reference

File I/O Functions
LockFileEx
OVERLAPPED