Microsoft KB Archive/245557

= PRB: Current Directory Changes After OL2000 Installation =

Article ID: 245557

Article Last Modified on 8/25/2005

-

APPLIES TO


 * Microsoft Messaging Application Programming Interface
 * Microsoft Outlook 2000 Standard Edition

-



This article was previously published under Q245557



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.



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:


 * 1) include "windows.h"
 * 2) include "mapix.h"
 * 3) 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.

Keywords: kbmsg kbprb KB245557

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.