共用方式為


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

請參閱

參考

CAtlFileMappingBase 類別