CAtlFileMappingBase::OpenMapping

Call this method to open a named file-mapping object for the specified file.

HRESULT OpenMapping(
   LPCTSTR szName,
   SIZE_T nMappingSize,
   ULONGLONG nOffset = 0,
   DWORD dwViewDesiredAccess = FILE_MAP_ALL_ACCESS 
) throw( );

Parameters

  • szName
    The name of the mapping object. If there is an open handle to a file-mapping object by this name and the security descriptor on the mapping object does not conflict with the dwViewDesiredAccess parameter, the open operation succeeds.

  • nMappingSize
    The mapping size. If 0, the maximum size of the file-mapping object is equal to the current size of the file-mapping object identified by szName.

  • nOffset
    The file offset where mapping is to begin. The offset value must be a multiple of the system's memory allocation granularity.

  • dwViewDesiredAccess
    Specifies the type of access to the file view and, therefore, the protection of the pages mapped by the file. See dwDesiredAccess in MapViewOfFileEx in the Windows SDK.

Return Value

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

Remarks

In debug builds, an assertion error will occur if the input parameters are invalid.

Requirements

Header: atlfile.h

See Also

Concepts

CAtlFileMappingBase Class

CAtlFileMappingBase Members

CAtlFileMappingBase::MapFile