Share via


UnlockFileEx (Windows CE 5.0)

Send Feedback

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

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

Parameters

  • hFile
    [in] Handle to a file that contains a region locked with LockFileEx. 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 Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. 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 seperately 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, 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 OS has not yet unlocked them.

Requirements

OS Versions: Windows CE 5.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

See Also

File I/O Functions | GetLastError | LockFileEx | OVERLAPPED

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.