Compartir a través de


CAtlFile::LockRange

Call this method to lock a region in the file to prevent other processes from accessing it.

HRESULT LockRange(
   ULONGLONG nPos,
   ULONGLONG nCount 
) throw( );

Parameters

  • nPos
    The position in the file where the lock should begin.

  • nCount
    The length of the byte range to be locked.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Remarks

Calls LockFile to lock a region in the file. Locking bytes in a file prevents access to those bytes by other processes. You can lock more than one region of a file, but no overlapping regions are allowed. When you unlock a region, using CAtlFile::UnlockRange, the byte range must correspond exactly to the region that was previously locked. LockRange does not merge adjacent regions; if two locked regions are adjacent, you must unlock each separately.

Requirements

Header: atlfile.h

See Also

Reference

CAtlFile Class

CAtlFile::UnlockRange

Other Resources

CAtlFile Members