首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

关于TFileStream构造时的有关问题

2012-02-04 
关于TFileStream构造时的问题TFileStream*sFSnewTFileStream( d:\\aa.exe ,Classes::fmOpenReadWrite||

关于TFileStream构造时的问题
TFileStream   *sFS   =   new   TFileStream( "d:\\aa.exe ",Classes::fmOpenReadWrite   ||   Classes::fmShareDenyNone);

错误如下:
E2316   'fmOpenReadWrite '   is   not   a   member   of   'Classes '
E2316   'fmShareDenyNone '   is   not   a   member   of   'Classes '
如果不加Classes::错误如下:
Ambiguity   between   'fmOpenReadWrite '   and   'Sysutils::fmOpenReadWrite '
Ambiguity   between   'fmShareDenyNone '   and   'Sysutils::fmShareDenyNone '

哪位大哥知道我该怎么办呀

[解决办法]
Classes 的确没有定义 fmOpenReadWrite,是不是在别的文件定义了同样的名称?

既然已经指出来 'Sysutils::fmOpenReadWrite ' 了,为什么用啊?
[解决办法]
Creates an instance of TFileStream.
__fastcall TFileStream(const AnsiString FileName, Word Mode);


TFileStream *sFS = new TFileStream( "d:\\aa.exe ",fmOpenReadWrite | fmShareDenyNone);


ps:
The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and a share mode or抏d together. The open mode must be one of the following values:

ValueMeaning

fmCreateCreate a file with the given name. If a file with the given name exists, open the file in write mode.
fmOpenReadOpen the file for reading only.
fmOpenWriteOpen the file for writing only. Writing to the file completely replaces the current contents.
fmOpenReadWriteOpen the file to modify the current contents rather than replace them.

The share mode must be one of the following values:

ValueMeaning

fmShareCompatSharing is compatible with the way FCBs are opened.
fmShareExclusiveOther applications can not open the file for any reason.
fmShareDenyWriteOther applications can open the file for reading but not for writing.
fmShareDenyReadOther applications can open the file for writing but not for reading.
fmShareDenyNoneNo attempt is made to prevent other applications from reading from or writing to the file.

If the file can not be opened, TFileStream throws an exception.
[解决办法]
不是无意,是一定会引用 Sysutils.hpp,而且 fmOpenReadWrite 等也是在 Sysutils里定义的,我是说有这个错误了,干嘛不用 Sysutils::fmOpenReadWrite

错误可能是因为在别的什么地方定义了 fmOpenReadWrite

热点排行