Platform SDK: Files and I/O |
The UnlockFile function 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.
BOOL UnlockFile( HANDLE hFile, // handle to file DWORD dwFileOffsetLow, // low-order word of start DWORD dwFileOffsetHigh, // high-order word of start DWORD nNumberOfBytesToUnlockLow, // low-order word of length DWORD nNumberOfBytesToUnlockHigh // high-order word of length );
Windows 95/98: dwFileOffsetHigh must be 0, the sign extension of the value of dwFileOffsetLow. Any other value will be rejected.
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.
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 behavior is not specified.
This function works on a file allocation table (FAT) – based file system only if the operating system is running SHARE.EXE.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
File I/O Overview, File I/O Functions, CreateFile, LockFile, UnlockFileEx