How to append text to a text file in WinAPI?

Posted by Bruce on Stack Overflow See other posts from Stack Overflow or by Bruce
Published on 2010-04-23T19:53:53Z Indexed on 2010/04/23 20:13 UTC
Read the original article Hit count: 216

Filed under:
|
|
|

Hi guys,

Ive got an annoying problem, I cant append any text to the text file. Every time I open it for writing, I overwrite the data. I tried to move the file pointer to the end of the file, but no result (no writing to the file at all). Here is the code:

INVOKE CreateFile, offset filePath, GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov hFile, eax
mov edx, 10
INVOKE SetFilePointer, hFile, 0, 0, FILE_END
INVOKE WriteFile, hFile, offset buffer, edx, ADDR SizeReadWrite, NULL
INVOKE CloseHandle, hFile

Any ideas? Thank you in advance!

© Stack Overflow or respective owner

Related posts about winapi

Related posts about handle