This morning I ran into a problem I encounter far too frequently: non-existent error codes. I’m calling the Win32 function LoadImage(). It’s returning back a NULL. According to the docs:
If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is NULL. To get extended error information, call GetLastError.
So I call GetLastError() and FormatMessage() to format it into a string.
So the reason why LoadImage could not load the image?
“The operation completed successfully.”
This is why I wish Microsoft would give developers access to the windows source from their symbol server. At least then I could dive in to LoadImage() and see what is going on. I may be calling it incorrectly but it’s hard to know with the given information. Things like this are a major productivity killer.

