Delpi FileStream Create Mode, FileOpen Access Mode

复制代码
  fmOpenRead       = $0000;
  fmOpenWrite      = $0001;
  fmOpenReadWrite  = $0002;
  fmExclusive      = $0004; // when used with FileCreate, atomically creates the file only if it doesn't exist, fails otherwise

  fmShareCompat    = $0000 platform; // DOS compatibility mode is not portable
  fmShareExclusive = $0010;
  fmShareDenyWrite = $0020;
  fmShareDenyRead  = $0030 platform; // write-only not supported on all platforms
  fmShareDenyNone  = $0040;
复制代码
constructor Create(const AFileName: string; Mode: Word); overload;

Call Create to instantiate a file stream for reading from or writing to the named file. Specify the name of the file and the way the file should be opened as parameters. 

function FileOpen(const FileName: string; Mode: LongWord): Integer;

Use FileOpen to open a file and obtain a file handle. The access mode value is constructed by or-ing one of the fmOpen constants with one of the fmShare constants defined in File open mode constants. If the return value is 0 or greater, the function was successful and the value is the file handle of the opened file. A return value of -1 indicates that an error occurred. 

 

The Mode parameter indicates how the file is to be opened. The Mode parameter consists of an open mode and (possibly) a share mode or'ed together. The open mode must be one of the following values:

Value 
Meaning 
fmCreate  
Create a file with the given name. If a file with the given name exists, open the file in write mode.  
fmOpenRead  
Open the file for reading only.  
fmOpenWrite  
Open the file for writing only. Writing to the file completely replaces the current contents.  
fmOpenReadWrite  
Open the file to modify the current contents rather than replace them.  

The share mode must be one of the following values:

Value 
Meaning 
fmShareCompat  
Sharing is compatible with the way FCBs are opened.  
fmShareExclusive  
Other applications can not open the file for any reason.  
fmShareDenyWrite  
Other applications can open the file for reading but not for writing.  
fmShareDenyRead  
Other applications can open the file for writing but not for reading.  
fmShareDenyNone  
No attempt is made to prevent other applications from reading from or writing to the file.  

If the file can not be opened, Create raises an exception. 

 

posted @   IAmAProgrammer  阅读(504)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示