Check the return value from LoadImage(). If the call works, it returns a handle, if not NULL. If it is returning a handle, then the problem is somewhere else, if it is returning NULL, call GetLastError() to find out why.