VC++ 2008, CLR Console App, being developed under win7 x64.
I'm using .net with MS Office v.12 PIA's to do some Excel automation, which is coming along quite nicely. But now, I'm starting the next portion of the code which involves doing some simple email transactions, so I'm trying to get MAPI working in my code. Basically, it reads the appropriate registry key to get the full path to the OLMAPI32.DLL file, and then tries to LoadLibrary/GetProcAddress from within that dll.
Here's a snippet:
using namespace System;
using namespace Microsoft::Office::Interop;
using namespace Microsoft::Win32;
int main(array<System::String ^> ^args)
{
RegistryKey^ subK = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Clients\\Mail\\Microsoft Outlook");
String^ mailDll = safe_cast<String^>(subK->GetValue("DLLPathEx"));
CStringW cStrMailDll = mailDll; //Just to put mailDll in a format that LoadLibrary() can read.
LPMAPIINITIALIZE mapiInit = NULL;
HMODULE mapiLib = LoadLibrary(cStrMailDll); // This Returns NULL
if(mapiLib == NULL)
{
printf("\nError: %d\n", GetLastError()); // System Error 193 - ERROR_BAD_EXE_FORMAT
return 1;
}
...(more code)
...
It comes as no shock to me that LoadLibrary sets system error 193: "%1 is not a valid Win32 application." After doing some research, I figure all I need to do is force x86 compile. So I go to Configuration Manager, and under Active solution platform, my only choices are Win32, New and Edit. So I click New, type in "x86" under "Type or select the new platform", and click "Copy settings from" to select "Any CPU" or something suitable, but my only choice is Win32, and ! I figured maybe it was because I was already targeting .net, so to test that theory, I started a new project, this time as a Win32 Console App. Even under that type of project, my only choice is Win32. The x86, x64, Any CPU, and Itanium that I've heard about don't exist in my VS2008!
So I'm at a loss here. How do I force VS to compile my exe as x86 so that I can use the mapi interface? Or is there a 64-bit version of OLMAPI32.DLL that I can use? How the heck do I get MAPI working in my code if there's no 64-bit library for it and VS gives me the dear-in-the-headlights when I try to set up my environment for x86? I just can't believe that my 64-bit environment automatically disqualifies me from using MAPI.
Thanks
I believe Win32 is x86 in Visual Studio C++