Hy, this code does't work. but why ?



.data
filename DB 200 DUP(0)
data DB 200 DUP(0)
lenght DB 200 DUP(0)

.data?
hFile DWORD ?

.code
PUBLIC SchreibeDaten

SchreibeDaten PROC Dfilename:DWORD, Ddaten:DWORD
LOCAL bytes_written:DWORD
INVOKE lstrcpy, ADDR filename, Dfilename
INVOKE lstrcpy, ADDR data, Ddaten
INVOKE CreateFile, ADDR filename, GENERIC_READ OR GENERIC_WRITE, NULL, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
.IF EAX ==INVALID_HANDLE_VALUE
INVOKE MessageBox, NULL, ADDR filename, NULL, NULL
RET
.ENDIF
MOV DW_hFile, EAX
INVOKE lstrlen, ADDR data
INVOKE lstrcpy, ADDR lenght, EAX
INVOKE WriteFile, hFile, ADDR data, ADDR lenght, ADDR bytes_written, NULL
.IF EAX != NULL
INVOKE MessageBox, NULL, ADDR filename, NULL, NULL
RET
.ENDIF
INVOKE CloseHandle, DW_hFile



I call the funktion with this parameters:
"D.\Option.ini" and data:"Huhu @ALL"

When I call this function the file get no contens :confused:

Regards FF
Posted on 2003-04-16 14:48:33 by Forginforcer
return values aren't there for CPU faeries to toy with and a value is different from a pointer.
you will need to go through Iczelion's tutorials at least once. Then you'll see what you're doing wrong and it will be a service to yourself :/


Teach a man to fish...
Posted on 2003-04-16 14:58:14 by Hiroshimator
I have found the bug.
I have mixed DB mixed up with DW.

But one question:
Why is assembler slower than c++, at write files ?
I have included Assembler in C++, and the assembler routine is slower than the C++ one. In c++ I have used filestream.
Posted on 2003-04-16 15:36:28 by Forginforcer
WriteFile is an API, a part of windows, call mister bill gates :)
Posted on 2003-04-16 15:54:55 by Bit7

Why is assembler slower than c++, at write files ?


Maybe the C compiler generated better assembly code than you. :rolleyes:
Posted on 2003-04-16 16:04:58 by bazik
@bazik
cool, you are very funny ! I reay have to laught ! *hhihihi*
Your are totaly right !

But, Its an Api call und shouldnt that slow.
It is so slow, becaue every call need a big inizisalisation ?

Bye ! Your FF(but not the condom) !
Posted on 2003-04-16 16:17:03 by Forginforcer