Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAPIInitialize without error message boxes

A 64-bit copy of Outlook is installed, and a 32-bit program is trying to call MAPIInitialize(). It will fail, which is OK, but it will also display a modal message box and block until the message box is dismissed.

MAPIInitialize error message

How can I prevent the very unhelpful message box from appearing?

(In case it matters, I'm linking to mapi32.lib and calling it from a C++ program. The OS is Windows 7.)

like image 855
user38329 Avatar asked Jan 30 '26 14:01

user38329


1 Answers

Your code ends up calling a stub 32 bit dll. Are you statically linking to mapi32.dll? You need to load the right dll from the Program Files folder. LoadLibrary() will return 0 and GetLastError will be ERROR_BAD_EXE_FORMAT if the bitness of the dll does not match the bitness of your process.

like image 189
Dmitry Streblechenko Avatar answered Feb 01 '26 23:02

Dmitry Streblechenko