You're overwriting it and thus causing a leak. That's why you must close each handle first.
Yes! After you're done with the handle (don't need it anymore), you must close it. And if you assign it again, as you do, you're overwriting the previous value, so it becomes lost forever. CreateFile creates a new handle and returns it.Quote:
But in essence, what you are saying is that i should call CloseHandle inside the loop? Like this..
Perhaps you should read my above reply again, if you haven't already.Quote:
Actually, i just assumed that Elysias proposal would work, didn't really think too much about what the code actually does, i guess that was a bit naive of me...
If the integers don't match up when i'm dividing, it gets truncated right? So if i have say 889 Bytes that i wan't to split into 3 files, itt'l truncate the last byte? Shouldn't i just add 1 to the size of the buffer and the last call to WriteFile then? To make sure it gets it all?
You need to weak the formula a bit, that's all. Your files won't be 100% the same size, but that's something you're going to have to live with.