Share via


PRELEASEFILELOCKSTATE (Compact 2013)

3/26/2014

This function is a prototype to be implemented by the file system driver (FSD) and used by Lock Manager to return the lock state of the specified file. This function must be called to exit the file lock state's critical section.

Syntax

typedef BOOL (*PRELEASEFILELOCKSTATE)(
    DWORD dwFile,
    PFILELOCKSTATE* ppFileLockState
);

Parameters

  • dwFile
    Specifies the file.
  • ppFileLockState
    Pointer to a FILELOCKSTATE structure associated with the file referenced by dwFile.

Return Value

TRUE indicates that the file is locked.

Remarks

This is a function prototype to allow passing functions as parameters. An OEM must implement functions conforming to this type definition if using the FSDMGR_AcquireFileLock and the FSDMGR_CloseFileLockState macros from the MyFSD_LockFileEx and the MyFSD_UnLockFileEx functions.

The following code example shows a simple implementation:

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

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;
}

See Also

Reference

FSD Data Types
MyFSD Functions
PACQUIREFILELOCKSTATE
FSDMGR_CreateFileHandle
MyFSD_CreateFileW
MyFSD_FindFirstFileW
FILELOCKSTATE