invoke CreateFile,ADDR buffer,\
mov hFile,eax
invoke GetFileSize,hFile,0
mov fsize,eax
invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,fsize
mov hMemory,eax
invoke GlobalLock,hMemory
mov pMemory,eax
invoke ReadFile,hFile,pMemory,fsize,ADDR SizeRead,NULL
invoke SendMessage,hwndEdit,WM_SETTEXT,NULL,pMemory
invoke CloseHandle,hFile
invoke GlobalUnlock,pMemory
invoke GlobalFree,hMemory

I tried to read file size about 600kb and didn't happen anything
Actually I get filesize with GetFileSize and Allocate memory but don't know why this doesn't work .... works fine with small file ...
Posted on 2002-05-15 00:12:03 by Gandalf
You call API functions, but you never check to see if the API function failed or worked, that is an *extremely* bad coding practice. You have CreateFile set to only open existing files, what if that file doesn't exist? Even if the file does exist, that call may still fail, for instance if another app has the file open with an exclusive lock. File size has nothing to do with whether that call works or not.
Posted on 2002-05-15 00:32:52 by sluggy
I agree with sluggy but his problem I think is not that file wasn't read or memory wasn't allocated.
here is the problem I think.
invoke SendMessage,hwndEdit,WM_SETTEXT,NULL,pMemory
If his OS one of 9x or Millenium, the edit control there can handle
no more then 64kb-1.
And even in close sizes like 63kb 62 kb it can fail to load string.
Posted on 2002-05-15 00:43:50 by The Svin
Thx guys I think you are right Svin ...

I guess I better use rich edit right ?

Well thx for the advise shuggy ...

Sometimes I forgot to check the error ...

But this was pretty simple one and I thought something about
memory or edit window was problem ....

Is there any other method to read big file like WordPad.exe ?
Posted on 2002-05-15 00:51:36 by Gandalf
The most important thing to remember Gandalf, is to do your bug fixing in a methodical way, in order of execution, as fixing a problem earlier in the code can fix a problem that is happening later in the code.

Having said that, i would say Svin's answer is the correct one, i had forgotten about the maximum size of text you could allocate to a text (edit) control.
Posted on 2002-05-15 02:03:07 by sluggy
Btw, use HeapAlloc instead of Local/GlobalAlloc. LocalAlloc=GlobalAlloc,
and both end up calling HeapAlloc... so you might as well do it directly.
Posted on 2002-05-15 06:37:07 by f0dder
You can try file mapping. One of Iczelion's tuts covers the basics of..
Posted on 2002-05-15 07:25:38 by MArtial_Code