Share via


CAtlTemporaryFile::LockRange

Call this method to lock a region in the temporary 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

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. To successfully unlock a region, use CAtlTemporaryFile::UnlockRange, ensuring the byte range corresponds 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

CAtlTemporaryFile Class

CAtlFile::LockRange

CAtlTemporaryFile::UnlockRange