Quote Originally Posted by Marc G View Post
Why GlobalAlloc() after all?
You can just use standard C++ memory allocation.
Preferably using some kind of RAII object like std::vector.
So, instead of GlobalAlloc(), create std::vector of the required size, and pass the address of the first element to ReadFile() to fill the vector with the data.
All memory will be cleaned up automatically.
From looking at the posts, I sort of assumed this was c code and not c++ ??...