I think that my add-in is stable now with some minor exceptions in some cases. I've post it as soon as I remove all the bugs I can find. Here is a problem I faced today: I invoke CreteFile - open existing, create file mapping and after that create a map view of the file. I close the handle to the file I've opened. After that I create an empty file in wich I want to put the first file through WriteFile,hTmp,hMapView... etc. where hTmp is the new empty file and hMapView is the memory mapped file. On some occasions it doesn't write anything to the new empty file. When invoking GetLastError and FormatMessage, I receive "The supplied user buffer is not valid for the requested operation." Can anybody tell me what the heck is that and why this problem appears on very few files. Another thing to consider is that it happens everytime on these definite files. Any suggestions are welcome and would be greatly appreciated!


/siddhartha
Posted on 2004-12-20 05:30:45 by siddhartha
Do you do error checking after CreateFile, CreateFileMapping and MapViewOfFile?

Also, why do you use MMF for file copying? It has a bit more overhead and is slightly slower (well, *very* slightly) than a readfile+writefile loop. The main thing, however, is that you will only be able to handle files of a limited size (especially on Win9x, because of the limited size of the shared memory area, where MMFs are located.)
Posted on 2004-12-20 07:36:26 by f0dder
maybe it is because you are closing the handle of the first file? I've always kept the handle open untill calling UnMapViewOfFile
Posted on 2004-12-20 10:57:47 by QuantumMatrix1024
OK, f0dder, that's true. But it's just a simple installer. Moreover readfile is already outdated and MS don't recommend using it.

QuantumMatrix1024 -> You don't have to keep the handle to the file itself open. After CreateFileMapping you can close the handle to the original file. The problem is now fixed - it was my fault which was very hardly traceable...



/siddhartha
Posted on 2004-12-26 23:14:08 by siddhartha
Since when is readfile outdated? You might be thinking about _lread ... and I'd still recommend against using MMF for file copying.
Posted on 2004-12-27 11:06:11 by f0dder
Yeah, I've made mistake, f0dder :)




/siddhartha
Posted on 2004-12-29 00:52:46 by siddhartha