hi all,
i have a prob...
i need to write a text line to an existing .txt
i try WriteFile but nothing...
i think my prob is geting the handle of the .txt file
can someone help me?
by all
5k3l3t0r
Posted on 2007-02-03 14:23:35 by 5k3l3t0r
Hi 5k3l3t0r, how are things?

Show us your code? We'll push you in the right direction :)
Posted on 2007-02-03 15:32:29 by JimmyClif
Hi, jimmy...
i can't give you my code, because i'm not in my home...(i don't have internet conexion :(...)
but is something like this:
======================================================================
.elseif eax==1018  ;my button
invoke CreateFile,addr dir,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,0,0
.if eax!=INVALID_HANDLE_VALUE
mov hFile, eax
invoke WriteFile,hFile,offset string,SIZEOF string,offset WriteSize,0
.else
invoke MessageBeep,MB_OK
.endif
invoke CloseHandle,hFile
======================================================================
can you correct the code and put some notes?
tkx
bye...
5k3l3t0r
Posted on 2007-02-03 16:24:33 by 5k3l3t0r
Maybe you forgot the call to SetFilePointer before your call to WriteFile.


invoke SetFilePointer, hFile,0,0, FILE_END
Posted on 2007-02-03 16:31:05 by JimmyClif
hi...
TKX, you solve my prob... so simple for you, very hard for me...:(
i just need to change line... do you know how? the text appears all in the same line that it was before, but i want to put my text in the next line. do you understand? sorry, is not easy for me to explain.

oh, did you receive my e-mail, last week?

bye
Posted on 2007-02-03 16:46:35 by 5k3l3t0r
hi jimmy... i solved my prob... (the change line) the solution was:

string        db          'my string',10,13

and before i have

string        db          'my string',0

bye, and tkx again...
5k3l3t0r



 
Posted on 2007-02-03 17:56:49 by 5k3l3t0r
Great. Good job! :D


... and no I haven't received any email. I checked my trash and my spam folder. Did you send it to gmail?

... and btw: use: string        db          'my string',10,13,0
Posted on 2007-02-03 18:04:18 by JimmyClif
Although 10,13 works, the standard sequence is CR/LF or 13,10.

Also, WriteFile is a binary write, so embedded zero bytes will be written to the file. The number of bytes written is controlled by a size argument.
Posted on 2007-02-05 20:43:28 by tenkey
Nevertheless, it's a good habit to zero-terminate all strings ;)
Posted on 2007-02-05 21:32:59 by ti_mo_n

Nevertheless, it's a good habit to zero-terminate all strings ;)

As long as you only write sizeof(string)-1 or strlen(string) to the file.
Posted on 2007-02-06 03:26:35 by f0dder