在CFile类中可以通过标记CFile::shareExclusive; CFile::shareDenyRead; 等实现打开文件的独占或共享。
在C++中使用iostream流如何实现上面的功能?

解决方案 »

  1.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/_iostream_fstream.3a3a.open.aspnProtThe file protection specification; defaults to the static integer filebuf::openprot, which is equivalent to the operating system default, filebuf::sh_compat, under MS-DOS. The possible nProt values are as follows:    * filebuf::sh_compat   Compatibility share mode (MS-DOS only).    * filebuf::sh_none   Exclusive mode no sharing.    * filebuf::sh_read   Read sharing allowed.    * filebuf::sh_write   Write sharing allowed.      The filebuf::sh_read and filebuf::sh_write modes can be combined with the logical OR ( || ) operator.
      

  2.   

    如果是标准c++的话
    可以先seekg 到末尾
    然后tellg