News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Appending to a file

Started by Citric, June 24, 2005, 10:57:07 AM

Previous topic - Next topic

Citric

Hi all

When opening a file like ->

invoke CreateFile,ADDR fileName,GENERIC_WRITE,NULL,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL
invoke WriteFile,[hLogger],ADDR pText,eax,ADDR numBytes,NULL

is there any way to append the file when it is open for a second time?

I have looked throught MSDN and google to find a simple solution but most the time examples use fopen and other starndard c stuff.

Any help is appreciated?

Cheers Adam

Tedd

No snowflake in an avalanche feels responsible.

brixton

Yeah if you know how far to move the pointer then you can use SetFilePointer or _lseek I believe and get to the end of the file, so the next write will append to it.
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

Citric

Cheers

that give me another avenue to chase down!

Thanks Adam

Citric

And MSDN gave me the rest!

invoke CreateFile,ADDR fileName,GENERIC_WRITE,NULL,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL

invoke SetFilePointer,[hLogger],0,NULL, FILE_END

invoke WriteFile,[hLogger],ADDR pText,eax,ADDR numBytes,NULL

for peoples future reference!

Tedd

This is what I meant.
SetFilePointer allows you to move to the end anyway (without you needing to know where that is) ::)
And if not, you could get the file's size :bdg

Anyway, problem solved :U
No snowflake in an avalanche feels responsible.