我现在的问题是:每次打开文件都是从头开始写文件(导致老信息被覆盖),而我希望是“打开一个文件,如果存在,新内容添加在文件尾部;如果文件不存在,则创建文件! HANDLE m_hLogFile = CreateFile(fname,
GENERIC_WRITE,
FILE_SHARE_READ,
&sa,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL); WriteFile(m_hLogFile,buf,lstrlen(buf),&num,NULL);
使用了 SetEndOfFile,也无效!那位帅哥有经验的,分享下...
GENERIC_WRITE,
FILE_SHARE_READ,
&sa,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL); WriteFile(m_hLogFile,buf,lstrlen(buf),&num,NULL);
使用了 SetEndOfFile,也无效!那位帅哥有经验的,分享下...
解决方案 »
- 设备无关位图的显示..
- vs2005与vc6不兼容问题.
- 找个高手当老师,有人愿意+QQ328056469
- 怎么将CEdit的光标移到里面显示的内容的最后一行?
- 在使用CB_SETITEMHEIGHT设置一个ComboBox控件列表项的高度时,有没有什么办法能将指定列表项的高度设成0呢?
- 模仿萧峰的《串口调试助手》写了个UDP调试助手,暂时没地方上传,需要的留下E-mail。
- 谁有mail程序的源代码
- 大家给个建议好吗
- 由CreateFileMapping生成的内存映象文件如何读出来,并写入txt文件中?
- mfc做的exe需要哪些dll?
- mfc写一个桌面
- vc6.0编写一个简单的 opengl链接出问题了
m_Ol.hEvent = CreateEvent(xxxx);WriteFile(xxxx&m_Ol); //开始写入数据读就不用说了把
写文件 就要设置OVERLAPPED
麻烦的
直接定位到文件末尾多方便
m_Ol.hEvent = CreateEvent(xxxx);WriteFile(xxxx&m_Ol); //开始写入数据读就不用说了把
FILE_APPEND_DATA|SYNCHRONIZE,
FILE_SHARE_READ,
&sa,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
HANDLE hFile,
LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh,
DWORD dwMoveMethod
); Parameters
hFile
[in] Handle to the file whose file pointer is to be moved. The file handle must have been created with GENERIC_READ or GENERIC_WRITE access to the file.
lDistanceToMove
Low-order 32 bits of a signed value that specifies the number of bytes to move the file pointer. A positive value for lDistanceToMove moves the file pointer forward in the file, and a negative value moves the file pointer backward. Note that you cannot use a negative value to move back past beyond the beginning of a file.
lpDistanceToMoveHigh
Not supported; must be NULL or point to a value of zero.
dwMoveMethod
[in] Starting point for the file pointer move. The following table shows possible values for this parameter.
Value Description
FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
FILE_CURRENT Indicates that the starting point is the current value of the file pointer.
FILE_END Indicates that the starting point is the current EOF position.