CFile dibFile(filename,CFile::modeWrite|CFile::modeCreate);
这里第二个参数为什么要写成CFile::modeWrite|CFile::modeCreate?不懂是啥意思,请指教~

解决方案 »

  1.   

    https://msdn.microsoft.com/en-us/library/cz0a83sb(v=vs.80).aspx
      

  2.   

    文件如果未创建就创建 如果已存在就不创建 后面write么是代表可以往里面写操作
      

  3.   

    class CFile : public CObject
    {
    DECLARE_DYNAMIC(CFile)public:
    // Flag values
    enum OpenFlags {
    modeRead =          0x0000,
    modeWrite =         0x0001,
    modeReadWrite =     0x0002,
    shareCompat =       0x0000,
    shareExclusive =    0x0010,
    shareDenyWrite =    0x0020,
    shareDenyRead =     0x0030,
    shareDenyNone =     0x0040,
    modeNoInherit =     0x0080,
    modeCreate =        0x1000,
    modeNoTruncate =    0x2000,
    typeText =          0x4000, // typeText and typeBinary are used in
    typeBinary =   (int)0x8000 // derived classes only
    }; enum Attribute {
    normal =    0x00,
    readOnly =  0x01,
    hidden =    0x02,
    system =    0x04,
    volume =    0x08,
    directory = 0x10,
    archive =   0x20
    }; enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 }; enum { hFileNull = -1 };就是CFile 定义的 枚举
      

  4.   

    CFile::modeCreate   Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.创建新文件。如果文件已经存在,它将被截断为0长度
    CFile::modeWrite   Opens the file for writing only.
      

  5.   

    请参考MSDN文档说明~