LockFileEx function kernel32

Win32Result<bool> LockFileEx(
  1. HANDLE hFile,
  2. LOCK_FILE_FLAGS dwFlags,
  3. int nNumberOfBytesToLockLow,
  4. int nNumberOfBytesToLockHigh,
  5. Pointer<OVERLAPPED> lpOverlapped,
)

Locks the specified file for exclusive access by the calling process.

This function can operate either synchronously or asynchronously and can request either an exclusive or a shared lock.

To learn more, see learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-lockfileex.

Implementation

Win32Result<bool> LockFileEx(
  HANDLE hFile,
  LOCK_FILE_FLAGS dwFlags,
  int nNumberOfBytesToLockLow,
  int nNumberOfBytesToLockHigh,
  Pointer<OVERLAPPED> lpOverlapped,
) {
  final result_ = LockFileEx_Wrapper(
    hFile,
    dwFlags,
    NULL,
    nNumberOfBytesToLockLow,
    nNumberOfBytesToLockHigh,
    lpOverlapped,
  );
  return .new(value: result_.value.i32 != FALSE, error: result_.error);
}