Another problem !
i was trying to write and read line from file, and i understand writing but how am i gonna
read a file line from file and display it for example in message box or edit control ????

writing is easy beacuse i declare string which i want to write like this

mystring db 'This will be writen in da file !',0

and than i use winapi CreateFile n WriteFile and all is good but

when i want to read that line from file (using ReadFile) i dont know what to put in this place

HANDLE hFile, // handle of file to read
LPVOID lpBuffer, // address of buffer that receives data <------- THIS PLACE
DWORD nNumberOfBytesToRead, // number of bytes to read
LPDWORD lpNumberOfBytesRead, // address of number of bytes read
LPOVERLAPPED lpOverlapped // address of structure for data

i hope ull understand my question ! Sorry for my bad English !
Thnx in advance
Posted on 2003-04-07 05:13:46 by Casper
a buffer is enough allocated bytes for the bytes your trying to read from the file.

so in that spot your refering to you place an unused(or even used if you want) byte holder.

so for examples if i wanted to read 10 bytes from that file at a time

i'd declare in my data section

buffer rb 10

that reserves enough for what you want to read

now if i want to put it in the messagebox

push 0
push 0
push buffer
push 0
call MessageBox


invoke MessageBox,0,buffer,0,0

which ever you prefer for calling your messagebox, i hope that answered your question.
Posted on 2003-04-07 05:42:45 by Guy on ASM
Hi Casper,

There is also a very easy method to allocate fixed memory(=buffer).

invoke GlobalAlloc,GMEM_FIXED,number of bytes.
The return value is a pointer to the memory block.
Before finishing all,don't forget to free the allocated memory with GlobalFree.


Posted on 2003-04-07 11:27:16 by Vortex
Use HeapAlloc and HeapFree instead, global/localalloc are deprecated. For small buffers, use statically reserve data, for stuff larger than a bunch of kilobytes, dynamically allocated is usually better.
Posted on 2003-04-07 12:17:12 by f0dder