Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
void __cdecl _CRT_DEBUGGER_HOOK(int _Reserved)
{
    /* assign 0 to _debugger_hook_dummy so that the function is not folded in retail */
    (_Reserved);
    _debugger_hook_dummy = 0;
}


This is my function to test the connection to Outlook:

C#
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?
Posted

Now I have a solution for my problem.

I use the function GetCurrentDirectory(...) to save my log files. When I use the MAPIInitialize(...) and MAPILogoEx(...) functions then the current directory is changed to the installation path of office package. As I work on a Windows 7 machine I have no access to the folder programm files where the office package is installed. This means that I have no rights to save my log files and I get an exception.

As a result I save the path to the current directory when the program starts and so I have no problems anymore. :-)
 
Share this answer
 
Look at the call stack and see if there's an actual line in your code that's causing this. The code you posted from dbghook.c is a generic error stop, but something in your code (or the DLL) triggered it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900