# Function Reference

# _WinAPI_LockFile

Locks the specified file for exclusive access by the calling process

#include <WinAPIFiles.au3>
_WinAPI_LockFile ( $hFile, $iOffset, $iLength )

## Parameters

$hFile | Handle to the file.
$iOffset | The starting byte offset in the file where the lock should begin.
$iLength | The length of the byte range to be locked.

## Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

## Remarks

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.

## See Also

Search LockFile in MSDN Library.