Lockfileex

[DllImport("Kernel32.dll")][return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LockFileEx(IntPtr hFile,
   uint dwFlags,
   uint dwReserved,
   uint nNumberOfBytesToLockLow,
   uint nNumberOfBytesToLockHigh,
   ref OVERLAPPED lpOverlapped
);

Microsoft documentation: Link

Last updated