Recently I was asked to build a MFC application, and it worked on my development PC, but after packaging all the dlls, the application does not run, and an error with 0x00000007 pops up.
I then opened the exe file with Dependency Walker:
Note the highlighted dll, their icons in the tree views are different from others. It might be that the 64 bit dll is needed, yet what is packaged is the 32 bit counterpart.
After changing the 32bit dll with the right 64 bit ones, now the program runs very well!
So if you encounter the same 0x00000007 error, first consider if you are using the right 32bit or 64bit executable/extension? Also take good use of Dependency walker to make your life easier.