我正在使用Delphi 2010,并且想寻找一种使用CreateFile Windows API函数来将数据追加到指定文件中而不是覆盖它的方法。
我不是在寻找其他可选的方式,例如Append()、Rewrite()或类似的方式。我特别想通过使用CreateFile Windows API函数来实现这一点。
我尝试使用:
// this will open existing file but will **overwrite** data in the file.
fHandle:= CreateFile(PChar(FName), GENERIC_READ or GENERIC_WRITE, 0,
nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
// this will recreate file each time therefore deleting its original content
fHandle:= CreateFile(PChar(FName), GENERIC_READ or GENERIC_WRITE, 0,
nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
非常感谢,
这是需要翻译的内容。
TFileStream
呢?它是该API的易于使用的包装器。或者使用CreateFile
和THandleStream
。 - Sir Rufo