MyFSD_LockFileEx (Windows CE 5.0)

Send Feedback

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

BOOL MyFSD_LockFileEx(  PFILE pFile, 
  DWORDdwFlags, 
  DWORDdwReserved, 
  DWORDnNumberOfBytesToLockLow, 
  DWORDnNumberOfBytesToLockHigh, 
  LPOVERLAPPEDlpOverlapped
);

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 the possible values for dwFlags.
    Value Description
    LOCKFILE_EXCLUSIVE_LOCK The function requests an exclusive lock. If this flag is not specified, the function requests a shared lock.
    LOCKFILE_FAIL_IMMEDIATELY The 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 Values

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

Remarks

All FSD functions can be called re-entry; therefore, FSD developers must take this into account when developing an FSD.

Though the function requires an OVERLAPPED structure, it does not support asynchronous locking. In Windows CE, the OVERLAPPED structure is used only to describe the byte range to be locked. Fields other than OffsetHigh and Offset within the OVERLAPPED structure should be 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
        );
}

The Fsdmgr component is a DLL that manages all operating system (OS) interaction with installable files systems. Each installable file system requires an FSD, which is a DLL that exports an API needed to support 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, then its DLL is MyFSD.dll and its exported functions are prefaced with MyFSD_*.

Requirements

OS Versions: Windows CE 5.0 and later.
Header: Fsdmgr.h.
Link Library: Fsdmgr.lib.

See Also

CreateDirectory | CloseHandle | FSDMGR_CreateFileHandle | FSDMGR_RegisterVolume | MyFSD_CreateDirectoryW | MyFSD_CreateFileW | MyFSD_DeleteFileW | MyFSD_FindClose | MyFSD_FindFirstFileW

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.