Hello community!
I have a dll to connect to the address book of Outlook. The dll works fine on Outlook 2003, 2007 but not on Outlook 2010.
When I want to close the main exe programm the Visual Studio returns a failure and the debugger jumps to following position:
dbghook.c
void __cdecl _CRT_DEBUGGER_HOOK(int _Reserved)
{
(_Reserved);
_debugger_hook_dummy = 0;
}
This is my function to test the connection to Outlook:
BOOL ConnectOutlook(LPTSTR lpstrProfileName, LPTSTR lpstrProfilePwd)
{
BOOL bReturn = FALSE;
HRESULT hRes = NULL;
LPMAPISESSION lpSession = NULL;
LPADRBOOK lpAdrBook = NULL;
ULONG ulObjType = 0;
LPABCONT lpABContainer = NULL;
LPMAPITABLE lpTableRoot = NULL;
hRes = MAPIInitialize(NULL);
if(hRes != S_OK)
{
goto cleanup;
}
hRes = MAPILogonEx(NULL, lpstrProfileName, lpstrProfilePwd, MAPI_EXTENDED | MAPI_NEW_SESSION |
MAPI_EXPLICIT_PROFILE | MAPI_UNICODE | MAPI_MULTITHREAD_NOTIFICATIONS, &lpSession);
if(hRes != S_OK)
{
goto cleanup;
}
hRes = lpSession->OpenAddressBook(0, NULL, 0, &lpAdrBook);
if(hRes != S_OK)
{
goto cleanup;
}
hRes = lpAdrBook->OpenEntry(0, NULL, NULL, 0, &ulObjType, (LPUNKNOWN*)&lpABContainer);
if(hRes != S_OK)
{
goto cleanup;
}
hRes = lpABContainer->GetHierarchyTable(MAPI_UNICODE, &lpTableRoot);
if(hRes != S_OK)
{
goto cleanup;
}
bReturn = TRUE;
cleanup:
if(lpTableRoot)
{
lpTableRoot->Release();
}
if(lpABContainer)
{
lpABContainer->Release();
}
if(lpAdrBook)
{
lpAdrBook->Release();
}
if(lpSession)
{
lpSession->Logoff(NULL, NULL, NULL);
lpSession->Release();
}
MAPIUninitialize();
return bReturn;
}
Can someone help me, please?