Compartilhar via


PACQUIREFILELOCKSTATE

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function is implemented by a file system driver (FSD). Used by Lock Manager to get the file lock state associated with the specified file when a lock is being modified.

Syntax

typedef VOID (*PACQUIREFILELOCKSTATE)(
    DWORD dwFile,
    PFILELOCKSTATE* ppFileLockState
);

Parameters

  • dwFile
    [in] File handle context passed to FSDMGR_InstallFileLockState. This should be the pointer to the value that the FSD passed to the FSDMGR_CreateFileHandle function when the file handle was created.
  • ppFileLockState
    [out] Pointer to a FILELOCKSTATE structure associated with the file referenced by dwFile.

Remarks

This function is required to enter the PFILELOCKSTATE critical section, lpcs in the following example, before returning the FILELOCKSTATE structure to the caller.

Before returning the FILELOCKSTATE structure to the caller, the function updates the dwPosLow, dwPosHigh, ** and ** dwAccess members of that structure, based on the current file pointer and access mode of the handle context referenced by dwFile.

The following code example shows a simple implementation:

BOOL MyAcquireFileLockState(DWORD dwPfh, PFILELOCKSTATE *ppFileLockState)
{
   PFILE pFileHandle = (PFILE)dwPfh;
   PINTERNALFILE pFile = pFileHandle->pInternalFile;
   if (NULL == pFile->FileLockState.lpcs) 
   {
      return FALSE;
   }
   // Acquire file lock state; exit in MyReleaseFileLockState.
   EnterCriticalSection(pFile->FileLockState.lpcs);
   // Obtain file position (64-bit offsets not supported).
   pFile->FileLockState.dwPosLow = pFileHandle->dwCurrentFileOffset;
   pFile->FileLockState.dwPosHigh = 0;
   // Obtain create access.
   pFile->FileLockState.dwAccess = pFileHandle->dwAccessMode;
   // Return file lock container.
   *ppFileLockState = &pFile->FileLockState;
   return TRUE;
}

This function is a Lock Manager function provided by File System Disk Manager (FSDMGR) to assist FSDs with implementing the MyFSD_LockFileEx and the MyFSD_UnLockFileEx functions.

Requirements

Header lockmgrtypes.h
Library Fsdmgr.lib
Windows Embedded CE Windows CE 5.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

MyFSD Functions
PRELEASEFILELOCKSTATE
FSDMGR_CreateFileHandle
MyFSD_CreateFileW
MyFSD_FindFirstFileW
FILELOCKSTATE