Click here to Skip to main content
15,883,978 members

Programm crashes with Outlook 2010

arstom asked:

Open original thread
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?
Tags: C++, Outlook

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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