Reputation: 580
I have converted a 32-bit WinForms application to 64-bit, but am unsure about what to with a call to MAPI32.DLL > MAPISendMail? I didn't think you could call a 32-bit dll directly from a 64-bit one, but thought I would see what happens. Curiously, it seems to work, but I don't know if it is safe.
The DLL is called as follows:
[DllImport("MAPI32.DLL")]
public static extern int MAPISendMail(IntPtr session, IntPtr hwnd, MapiMessage message, int flg, int rsv);
//...fill in message
// Call the API
int error = Mapi32.MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, Mapi32.MAPI_DIALOG, 0);
Is it safe to do this from a 64-bit WinForms app, or am I just lucky it doesn't crash?
Upvotes: 0
Views: 1536
Reputation: 49453
Yes, it is safe. An appropriate library will be used and loaded (mapi32.dll) from the appropriate system directory:
%windir%\system32\mapi32.dll
%windir%\syswow64\mapi32.dll
You can read more about that in the Building MAPI applications on 32-bit and 64-bit platforms article.
Upvotes: 1