Hi,

Can somebody tell me what's wrong in my test.exe?

If My program (Test.exe) opens a file (File.exe) and read it to allocated memory and then closes the file. Why can't test.exe then create a new file (FileCopy.exe) and write the data from the allocated memory to the new file.

Regards
Posted on 2003-01-12 14:26:05 by minor28
PSDK:
lpNumberOfBytesWritten (4th parameter)
Pointer to the variable that receives the number of bytes written. WriteFile sets this value to zero before doing any work or error checking.


You should set the 4the parameter of WriteFile to a pointer to a DWORD variable that will receive the number of bytes written (addr dwBytesWritten or something).

Thomas
Posted on 2003-01-12 14:31:02 by Thomas
Thank's Thomas,

That's elementary. I should have seen that myself. To my shame I must admit that I spent one hour without finding the solution. To my justification the attachment was an extract from a more extensive project.

Thank's again.
Posted on 2003-01-12 14:46:21 by minor28
This is just the matter of providing the correct parmaters to the apicalls.
invoke WriteFile,hFile,pMemory,FileSize,nBits,0

invoke GlobalUnlock,pMemory
CHANGE TO:
invoke WriteFile,hFile,pMemory,FileSize,addr nBits,0

invoke GlobalUnlock,addr pMemory
Posted on 2003-01-12 14:48:39 by natas
Originally posted by minor28
That's elementary. I should have seen that myself. To my shame I must admit that I spent one hour without finding the solution. To my justification the attachment was an extract from a more extensive project.


It's always easier for someone else to find a bug than the person who has been working on it for hours :)

Thomas
Posted on 2003-01-12 14:53:07 by Thomas