shareDenyNone 算不算是CFile类中文件的读写方式呢?

helloword222 2009-08-26 10:18:42
以下属于CFile类中文件的读写方式的是:( ABC )
A:modeRead B:modeWrite C:modeReadWrite D:shareDenyNone

我知道前3个都是,shareDenyNone算不算呢?它是用于共享文件的读和写
谢谢
...全文
1305 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyoxs 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用楼主 helloword222 的回复:]
我知道前3个都是,shareDenyNone算不算呢?
[/Quote]
雪影 2009-08-26
  • 打赏
  • 举报
回复
//OpenFlags定义了13种文件访问和共享模式:
enum OpenFlags {
//第一(从右,下同)至第二位,打开文件时访问模式,读/写/读写
modeRead = 0x0000,
modeWrite = 0x0001,
modeReadWrite = 0x0002,
shareCompat = 0x0000, //32位MFC中没用
//第五到第七位,打开文件时的共享模式
shareExclusive = 0x0010,//独占方式,禁止其他进程读写
hareDenyWrite = 0x0020,//禁止其他进程写
shareDenyRead = 0x0030,//禁止其他进程读
shareDenyNone = 0x0040,//允许其他进程写
//第八位,打开文件时的文件继承方式
modeNoInherit = 0x0080,//不允许子进程继承
//第十三、十四位,是否创建新文件和创建方式
modeCreate = 0x1000,//创建新文件,文件长度0
modeNoTruncate = 0x2000,//创建新文件时如文件已存在则打开
//第十五、十六位,文件以二进制或者文本方式打开,在派生类CStdioFile中用
typeText = 0x4000,
typeBinary = (int)0x8000
};
MoXiaoRab 2009-08-26
  • 打赏
  • 举报
回复
是的

nOpenFlags
Sharing and access mode. Specifies the action to take when opening the file. You can combine options listed below by using the bitwise-OR (|) operator. One access permission and one share option are required; the modeCreate and modeNoInherit modes are optional. The values are as follows:

CFile::modeCreate Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.

CFile::modeNoTruncate Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Furthermore, if the file being created already exists, the underlying file pointer will point to the beginning of the file. This flag guarantees the file to open, either as a newly created file or as an existing file. This might be useful, for example, when opening a settings file that may or may not exist already. This option applies to CStdioFile as well.

CFile::modeRead Opens the file for reading only.

CFile::modeReadWrite Opens the file for reading and writing.

CFile::modeWrite Opens the file for writing only.

CFile::modeNoInherit Prevents the file from being inherited by child processes.

CFile::shareDenyNone Opens the file without denying other processes read or write access to the file. Create fails if the file has been opened in compatibility mode by any other process.

CFile::shareDenyRead Opens the file and denies other processes read access to the file. Create fails if the file has been opened in compatibility mode or for read access by any other process.

CFile::shareDenyWrite Opens the file and denies other processes write access to the file. Create fails if the file has been opened in compatibility mode or for write access by any other process.

CFile::shareExclusive Opens the file with exclusive mode, denying other processes both read and write access to the file. Construction fails if the file has been opened in any other mode for read or write access, even by the current process.

CFile::shareCompat This flag is not available in 32-bit and 64-bit MFC. This flag maps to CFile::shareExclusive when used in CFile::Open.

CFile::typeText Sets text mode with special processing for carriage return–linefeed pairs (used in derived classes only).

CFile::typeBinary Sets binary mode (used in derived classes only).

CFile::osNoBuffer The system opens a file with no system caching. For more information see FILE_FLAG_NO_BUFFERING in CreateFile in the Windows SDK.

CFile::osWriteThrough The system writes through any intermediate cache and goes directly to disk. For more information see FILE_FLAG_WRITE_THROUGH in CreateFile in the Windows SDK.

CFile::osRandomAccess A file is accessed randomly. The system can use this as a hint to optimize file caching.

CFile::osSequentialScan A file is accessed sequentially from beginning to end. The system can use this as a hint to optimize file caching. For more information see FILE_FLAG_SEQUENTIAL_SCAN in CreateFile in the Windows SDK.

16,547

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧