PRB: Current Directory Changes After OL2000 Installation

ID: Q245557


The information in this article applies to:
  • Extended Messaging Application Programming Interface (MAPI), version 1.0
  • Microsoft Outlook 2000


SYMPTOMS

After installing Microsoft Outlook 2000, a call to MAPIInitialize (or anything that calls MAPIInitialize such as a CreateObject("MAPI.Session") call in CDO) causes the current directory to change to the directory where the Microsoft Outlook 2000 installed MAPI subsystem into.


MORE INFORMATION

Workaround

Begin by assuming the directory will change. First thing to do in the application is to select your current directory. Then, make a call to MAPIInitialize thereby forcing the directory to change. Finally, calculate a relative path between the two.

The following CDO code written in Microsoft Visual Basic and Extended MAPI code written in Microsoft Visual C++ can be used to reproduce this issue:

Visual Basic Code to Reproduce Issue:

' This sample assumes a reference to the CDO library. 
'
Dim objSess As MAPI.Session

Sub Main()
    'Display the default drive and dir, as well as that on C: and D:
    MsgBox "Def: " & CurDir & vbCrLf & _
           "Drive C: " & CurDir("C") & vbCrLf & _
           "Drive D: " & CurDir("D")

    'The following line of code will result in default drive and dir
    'changing. This is a major problem for apps that depend on relative
    'pathing.
    Set objSess = CreateObject("mapi.session")

    'Note drive and dir is different than on first msgbox
    MsgBox "Def: " & CurDir & vbCrLf & _
           "Drive C: " & CurDir("C") & vbCrLf & _
           "Drive D: " & CurDir("D")
End Sub 

Visual C++ Code to Reproduce Issue:


#include "windows.h"
#include "mapix.h"
#include "stdio.h"

void main()
{
	char	sDir[MAX_PATH];

	if(GetCurrentDirectory(MAX_PATH, sDir))
	{
		printf("Starting : %s\n", sDir);
	}

	HRESULT hr = MAPIInitialize(NULL);

	if(GetCurrentDirectory(MAX_PATH, sDir))
	{
		printf("Post Init: %s\n", sDir);
	}

	LPMAPISESSION	pSession = NULL;

	hr = MAPILogonEx(NULL, NULL, NULL, MAPI_LOGON_UI, &pSession);

	if(GetCurrentDirectory(MAX_PATH, sDir))
	{
		printf("Post Logon: %s\n", sDir);
	}
        
         pSession->Logoff(0, 0, 0);
	if (pSession) pSession->Release();

	MAPIUninitialize();
} 

This behavior has also been reported to occur on calls to other MAPI functions besides MAPIInitialze.

Additional query words:

Keywords : kbMAPI kbMsg kbOutlook kbVBp kbVC kbMAPI100 kbGrpMsg kbDSupport kboutlook2000
Version : WINDOWS:1.0,2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: December 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.