Compartilhar via


MyFSD_LockFileEx (Compact 2013)

3/26/2014

This function locks a region in the specified file for exclusive access by the calling process.

Syntax

BOOL MyFSD_LockFileEx(
  PFILE pFile, 
  DWORD dwFlags, 
  DWORD dwReserved, 
  DWORD nNumberOfBytesToLockLow, 
  DWORD nNumberOfBytesToLockHigh, 
  LPOVERLAPPED lpOverlapped
);

Parameters

  • pFile
    [in] Pointer to the value that an FSD passes to the FSDMGR_CreateFileHandle function when creating the file handle.
  • dwFlags
    [in] Flag value. The following table shows possible values.

    Value

    Description

    LOCKFILE_EXCLUSIVE_LOCK

    This function requests an exclusive lock. If this flag is not specified, the function requests a shared lock.

    LOCKFILE_FAIL_IMMEDIATELY

    This function returns immediately if it is unable to acquire the requested lock. If this flag is not specified, the function waits.

  • dwReserved
    Reserved. Set to zero.
  • nNumberOfBytesToLockLow
    [in] Low-order 32 bits of the length of the byte range to lock.
  • nNumberOfBytesToLockHigh
    [in] High-order 32 bits of the length of the byte range to lock.
  • lpOverlapped
    Pointer to an OVERLAPPED structure that is used with the lock request. This structure contains the file offset of the beginning of the unlock range.

Return Value

Nonzero indicates that the lock was successful. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

All FSD functions can be called re-entry. Therefore, take this into account when developing an FSD.

Though the function requires an OVERLAPPED structure, it does not support asynchronous locking. In Windows Embedded Compact, the OVERLAPPED structure is used only to describe the byte range to be locked. Members other than OffsetHigh and Offset are ignored.

FSDMGR provides the lock helper function FSDMGR_InstallFileLock to simplify implementation of this function in an FSD.

The following example shows a simple implementation.

BOOL MyFSD_LockFileEx ( PFILE pFile,
   DWORD dwFlags,
   DWORD dwReserved,
   DWORD nNumberOfBytesToLockLow,
   DWORD nNumberOfBytesToLockHigh,
   LPOVERLAPPED lpOverlapped )
{
   return FSDMGR_InstallFileLock ( MyAcquireFileLockState,
      MyReleaseFileLockState,
      (DWORD)pFile,
      dwFlags,
      dwReserved,
      nNumberOfBytesToLockLow,
      nNumberOfBytesToLockHigh,
      lpOverlapped );
}

FSDMGR is a DLL that manages all OS interaction with installable files systems. Each installable file system requires an FSD, which is a DLL that supports an installable file system. The name of the DLL for the FSD and the names of the functions it exports start with the name of the associated installable file system. For example, if the name of file system is MyFSD, its DLL is MyFSD.dll, and its exported functions are prefaced with MyFSD_*.

Requirements

Header

fsdmgr.h

Library

Fsdmgr.lib

See Also

Reference

MyFSD Functions
CreateDirectory
CloseHandle
FSDMGR_CreateFileHandle
FSDMGR_RegisterVolume
MyFSD_CreateDirectoryW
MyFSD_CreateFileW
MyFSD_DeleteFileW
MyFSD_FindClose
MyFSD_FindFirstFileW