CAtlFileMappingBase::CAtlFileMappingBase
构造函数。
CAtlFileMappingBase(
CAtlFileMappingBase& orig
);
CAtlFileMappingBase( ) throw( );
参数
- orig
用于创建新对象的副本的原始文件映射对象。
备注
使用现有对象,创建一个新文件映射对象,选择。 调用 CAtlFileMappingBase::MapFile 打开或创建一个特殊的文件的映射对象是必需的。
示例
int OpenMyFileMap()
{
// Create the file-mapping object.
CAtlFileMappingBase myFileMap;
// Create a file.
CAtlFile myFile;
myFile.Create(_T("myMapTestFile"),
GENERIC_READ|GENERIC_WRITE|STANDARD_RIGHTS_ALL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
OPEN_ALWAYS);
// The file handle.
HANDLE hFile = (HANDLE)myFile;
// Test the file has opened successfully.
ATLASSERT(hFile != INVALID_HANDLE_VALUE);
// Open the file for file-mapping.
// Must give a size as the file is zero by default.
if (myFileMap.MapFile(hFile,
1024,
0,
PAGE_READWRITE,
FILE_MAP_READ) != S_OK)
{
CloseHandle(hFile);
return 0;
}
// Confirm the size of the mapping file.
ATLASSERT(myFileMap.GetMappingSize() == 1024);
// Now the file-mapping object is open, a second
// process could access the filemap object to exchange
// data.
return 0;
}
要求
Header: atlfile.h