Search code examples
windowsdelphi64-bit

The application was unable to start correctly (0xc000007b)


I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.

When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".

Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.

  • both PCs are Windows 7, 64 bit
  • both have Delphi Xe2 starter edition which can only handle 32 bits
  • The app runs fine on my PC, but not on my friend's
  • Other Delphi apps run just fine on both PCs

Can anyone give me a hint as to how to track this down?


Solution

  • Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:

    • If a 32-bit app tried to load a 64-bit DLL.
    • Or if a 64-bit app tried to load a 32-bit DLL.
    • Or if a 64-bit app tried to run on a 32-bit Windows.

    To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker

    Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.

    (At least, at time of writting, namely 2022)

    Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.