• Sign in
 
  •  
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • About
  • Email Blog Author
  • RSS for posts
  • Atom
  • RSS for comments
    • OK
  • CDO (25)
  • Code Snippet (43)
  • Custom Providers (17)
  • Debugging (7)
  • DevMsgTeam (301)
  • Documentation (109)
  • DST (8)
  • EWS (7)
  • Exchange (109)
  • Gotchas (97)
  • Hotfix (28)
  • MAPI (240)
  • MAPI Download (54)
  • MFCMAPI (101)
  • MSDN (59)
  • Non Dev (11)
  • OOM (17)
  • Outlook (171)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (12)
  • Protocol Docs (20)
  • PST/OST (23)
  • Referrals (8)
  • Vista (12)
  • WrapPST (18)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2013 (3)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (2)
  • January 2013 (2)
  • December 2012 (4)
  • November 2012 (2)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (3)
  • June 2012 (2)
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)
Blogs I Read
  • Exchange

  • Raymond Chen [MSFT]

  • Larry Osterman [MSFT]

  • Peter David

  • Aaron Margosis [MSFT]

  • Jason Johnston [MSFT]

  • Matt Stehle (MSFT)

  • Patrick Creehan [MSFT]

  • Ryan Gregg [MSFT]

    Outlook PM
  • WebDav 101

    Dan Bagley (MSFT)
  • Dave Vespa [MSFT]

  • Randy Topken

    Outlook EE

November, 2006

MSDN Blogs > SGriffin's MAPI Internals > November, 2006
  • Subscribe via RSS
Sort by: Most Recent | Most Views | Most Comments
Excerpt View | Full Post View
  • SGriffin's MAPI Internals

    MAPI Editor Options

    Posted over 7 years ago
    by Stephen Griffin - MSFT
    • 4 Comments

    I thought it'd be interesting to document the registry values that MAPI Editor uses. Most of them are exposed in the UI through Options/Other.

    All of these registry keys are stored under the registry key HKEY_CURRENT_USER\Software\Microsoft\MFCMAPI.

    If a registry value is not found, the default is assumed.

    True/false values are stored with the usual convention of 0 being false, and any other value being true.

    Option: "Debug Output Tags (0 = None, ffff = Verbose. See Help.)"
    Reg Value: DebugTag (REG_DWORD)
    Default: 0
    Meaning: Sets which debug tags are enabled. The list of tags is in the Help (F1) dialog. Note that setting the high order tags (DBGWindowProc and DBGMenu) is liable to slow the process to a crawl.

    Option: "Enable Debug Output to File"
    Reg Value: DebugToFile (REG_DWORD)
    Default: 0
    Meaning: Whether debug output is written to a text file. If debug tags are enabled, but file logging is not, debug output is still emitted with OutputDebugString and can be monitored using a debug monitor such as dbgview.

    Option: "Debug Output File:"
    Reg Value: DebugFileName (REG_SZ)
    Default: c:\mfcmapi.log
    Meaning: File for debug output. This file is always opened in append mode. If this file cannot be opened, there will be no error dialog, but there should be an error output emitted through OutputDebugString.

    Option: "Parse Named Properties"
    Reg Value: ParseNamedProps (REG_DWORD)
    Default: true
    Meaning: If enabled, use GetNamesFromIDs to determine property names.

    Option: "Parse Named Properties for All Props (including those below 0x8000)"
    Reg Value: GetPropNamesOnAllProps (REG_DWORD)
    Default: false
    Meaning: Some providers return useful data when GetNamesFromIDs is passed a property ID outside the named property range. When this option is enabled, GetNamesFromIDs is called for all property IDs. Note that some providers will complain heavily.

    Option: "Throttle Level: If nonzero, limits the number of rows displayed in tables:"
    Reg Value: ThrottleLevel (REG_DWORD)
    Default: 0
    Meaning: A long time ago, MFCMAPI loaded tables on the main UI thread, so this option was necessary. Now that tables are loaded on a background thread, and table loads can be halted early by hitting Esc, this option isn't as useful. However, there may be times during testing when it is nice to only load the first few rows without having to hit Esc, so this option was left in.

    Option: "Register Notifications on Hierarchy Tables During Load"
    Reg Value: HierNotifs (REG_DWORD)
    Default: true
    Meaning: If enabled, when a folder is added to the tree view, load its hierarchy table and register for notifications. This allows for dynamic updates of the tree view as folders are created, deleted, move, or renamed. Folders which are being monitored in this manner show as bold in the tree view.

    Option: "Register Notifications on Hierarchy Tables During Node Expansion or Selection"
    Reg Value: HierExpandNotifs (REG_DWORD)
    Default: true
    Meaning: If enabled, when a node is selected or expanded in the tree that was not already registered for notifications, then register for notifications. If the folder isn't already bold, it will turn bold if the registration is successful.

    Option: "Allow Notifications on Root Container (may cause infinite loop in some Address Books)"
    Reg Value: HierRootNotifs (REG_DWORD)
    Default: false
    Meaning: Some providers really do not like when MAPI clients register for notifications on the root container. The Exchange Address book is a notable example. This option is disabled by default to avoid problems with such providers.

    Option: "Hierarchy Node Load Count: If nonzero, limits the number of child nodes for which the hierarchy table is automatically loaded:"
    Reg Value: HierNodeLoadCount (REG_DWORD)
    Default: 20
    Meaning: Registering for notifications on hierarchy tables is expensive. So when expanding a folder, this option determines how many children of the folder get registered for notification. This option exists primarily for Public Folders where a single folder is likely to have thousands of child folders.

    Option: "Perform GetProps call on objects when selecting or displaying. Extra properties will still display if unchecked."
    Reg Value: DoGetProps (REG_DWORD)
    Default: true
    Meaning: When enabled, whenever an row is selected in the upper pane, call GetProps to get a default list of properties for the item associated with the row. Regardless of how this is set, if Extra properties have been set, a GetProps call with the list of extra properties will still be performed.

    Option: "Use GetPropList to get property list for GetProps call (otherwise use NULL tag list)"
    Reg Value: UseGetPropList (REG_DWORD)
    Default: true
    Meaning: There are two ways to get a default list of properties. One, the default, is to call GetPropList to get a default list of property tags, then pass this list in to GetProps. The other way, which will happen if this option is disabled, is to call GetProps with NULL for the property tag list. Some providers have bugs which can be easily exposed by calling GetProps with a NULL property tag list.

    Option: "Allow duplicate columns of different types."
    Reg Value: AllowDupeColumns (REG_DWORD)
    Default: false
    Meaning: This is used in two places. The first is when SetColumns is called. Some providers allow for multiple columns with the same property tag, but different property types, such as one of PT_STRING8 and another of PT_UNICODE. Other providers treat this as an error. With this option enabled, two columns of the same ID but different types will be treated as different. With this option disable (default), the two columns will be merged, with the first type winning, before SetColumns is called. This option is also used in the Extra properties code for the bottom/right pane, using the same logic in constructing the list of property tags for GetProps.

    Option: "Default to using row data for property list instead of calling GetProps."
    Reg Value: UseRowDataForSinglePropList (REG_DWORD)
    Default: false
    Meaning: Normally, when a row is selected in the upper pane or a node is selected in the tree control, if an item which inherits from IMAPIProp can be opened, then result of GetProps calls will be used to fill the property pane. If an item cannot be opened (either due to an error or because the row is not associated with an item, like in the Rules table), then the row used for the upper pane or tree node is displayed. The status pane will indicate which data is being displayed. When this option is enabled, GetProps is never attempted.

    Option: "Use nice names for certain column headers and pull them to the front of the view"
    Reg Value: DoColumnNames (REG_DWORD)
    Default: true
    Meaning: For many types of tables, a default "interesting" set of properties has been selected. When these tables are displayed, these properties will be used to call SetColumns on the table. When this option is enabled, nice names are used in the column headers instead of the property tag names. Hovering over column headers will still display the property tag information in a tooltip bubble.

    Option: "When loading tables, display SetColumns edit dialog"
    Reg Value: EditColumnsOnLoad (REG_DWORD)
    Default: false
    Meaning: When enabled, after the set of columns to be used for a table is determined, display a dialog allowing the user to modify the set.

    Option: "Use MDB_ONLINE when calling OpenMsgStore"
    Reg Value: ForceMDBOnline (REG_DWORD)
    Default: false
    Meaning: See http://support.microsoft.com/kb/834496. If a cached mode profile is suddenly very slow in MAPI Editor, check that this option hasn't been set. Due to the way the underlying providers work, it may be necessary to restart MAPI Editor if the profile has already been opened before this option is toggled.

    Option: "Use MAPI_NO_CACHE when calling OpenEntry"
    Reg Value: ForceMapiNoCache (REG_DWORD)
    Default: false
    Meaning: See http://support.microsoft.com/kb/834496. If a cached mode profile is suddenly very slow in MAPI Editor, check that this option hasn't been set. Due to the way the underlying providers work, it may be necessary to restart MAPI Editor if the profile has already been opened before this option is toggled.

    Option: "Allow caching of IPersistMessage objects when opening Outlook forms in compose mode, which may prevent shutdown of certain versions of Outlook"
    Reg Value: AllowPersistCache (REG_DWORD)
    Default: false
    Meaning: Unless you're very interested in how form viewers work, don't mess with this option.

    Option: "Pass IMAPIProgress implementation to functions that take it"
    Reg Value: UseIMAPIProgress (REG_DWORD)
    Default: false
    Meaning: Many MAPI functions take an optional IMAPIProgress parameter. With this option enabled, MAPI Editor's implementation of this interface is passed to these functions. Output from this interface is displayed on the status pane. Not enabled by default because many providers' support for IMAPIProgress is minimal and buggy.

    Option: "Use IID_IMessageRaw when opening messages"
    Reg Value: UseMessageRaw (REG_DWORD)
    Default: true
    Meaning: See http://support.microsoft.com/kb/908074. When enabled, IID_IMessageRaw is used for opening messages. Most providers do not support this interface.

    Option: Not list in Other/Options. Instead, this is a check box on the Help (F1) dialog.
    Reg Value: DisplayAboutDialog (REG_DWORD)
    Default: true
    Meaning: When enabled, displays the Help (F1) dialog when MAPI Editor is started. Since this option can be toggled directly from the dialog, it is not listed in Options/Other.

  • SGriffin's MAPI Internals

    Folders Don't Do Named Props

    Posted over 7 years ago
    by Stephen Griffin - MSFT
    • 5 Comments

    A fellow engineer recently asked me how to set custom properties on a folder object in a PST. I reminded him that folders in the PST provider don't support named properties. He was surprised to hear this. I was surprised to learn that this hadn't actually been documented before. (If anyone can produce a link to previous documentation on this I'd be grateful!)

    Neither the Exchange provider (emsmdb32.dll) or the PST provider (mspst32.dll) support named properties on folders. Both will allow you to call GetIDsFromNames and GetNamesFromIDs, but neither will allow you to set a property in the 0x8000 to 0xFFFE range. This is contrary to the MAPI documentation, which suggests that providers which support named properties would support them for both message and folder objects.

    If you attempt to set a named property on a folder in a PST or cached mode (which is built on top of the PST provider), then you will get MAPI_E_NO_ACCESS in the SPropProblemArray structure returned by SetProps.

    If you attempt to set a named property on an Exchange folder, you will get MAPI_E_NO_SUPPORT in the problem array.

    Note that the documentation for Named Properties in the MSDN indicates that providers should return MAPI_E_UNEXPECTED_ID if they do not support named properties, so these error codes would appear to be, well, in error. However, I do not believe this is the case since the providers certainly do support named properties. They just don't support them on certain objects, a case the documentation doesn't allow for.

  • SGriffin's MAPI Internals

    The Intentional Memory Leak

    Posted over 7 years ago
    by Stephen Griffin - MSFT
    • 3 Comments

    So - there's a memory leak in Outlook's implementation of MAPI. That shouldn't be too much of a shock. Just about any sizable application is bound to have a leak or two. What's interesting about this leak is that it is intentional.

    A little history: We first shipped Simple MAPI back in MS Mail, circa 1992. Later on, when Extended MAPI was being developed for Windows 95, we chose to reimplement Simple MAPI as a wrapper around Extended MAPI. This reduced bug counts, simplified testing, etc. Everyone was happy. (Or so I've been told - I was still in school at the time!)

    As we neared RTM however, our testers started finding Simple MAPI applications which had worked fine with MS Mail but now crashed. Investigation showed that these applications were accessing memory which had been freed. Why?

    Let's digress a bit and look at a typical Simple MAPI function, MAPIResolveName:

    ULONG FAR PASCAL MAPIResolveName(
    	LHANDLE lhSession,
    	ULONG ulUIParam,
    	LPTSTR lpszName,
    	FLAGS flFlags,
    	ULONG ulReserved,
    	lpMapiRecipDesc FAR * lppRecip )

    There are two parameters of interest here: lhSession and lppRecip. lhSession can be used to pass in an existing session that was created with MAPILogon. Or it can be left NULL to let Simple MAPI create and use a temporary session for the duration of the call. lppRecip is used to pass back a structure - the resolved name. This structure is to be freed with MAPIFreeBuffer.

    How would we implement this function in Extended MAPI? It would look something like this (pseudo-code):

    if (!lhSession) 
    {
    	lhSession = InitializeMAPIAndLogonToProfile();
    	bTempSession = true;
    }
    DoWorkToResolveNames(lhSession,lppRecip);
    if (bTempSession) LogoffProfileAndUninitializeMAPI();
    return;

    So far so good. And as long as all the test harnesses for Simple MAPI pass a session in whenever they call MAPIResolveName, there's no problem. But what happens when we call MAPIResolveName without a session?

    It might help here to comment that MAPI handles it's own memory allocations. That's why we have a special function, MAPIFreeBuffer, for freeing memory. When MAPI is initialized, it creates a heap to handle all of it's allocations. Similarly, when MAPI is uninitialized, it destroys this heap.

    I'm sure the A students are bored with this lecture so I'll wrap it up now: In the original implementation, as soon as we clean up the temporary session and uninitialize MAPI, the heap from which lppRecip was allocated is destroyed. So any attempt to use it will result in a crash.

    To fix this, we were faced with two choices. Either completely rethink how memory is handled in Extended MAPI, or leak the heap whenever we uninitialize MAPI. We chose the leak. The first version of Extended MAPI we shipped back in Windows 95 contained this leak.

    Jump to today: That original version of Extended MAPI/Simple MAPI eventually forked to become the basis of both Outlook and Exchange's implementations of MAPI. While both implementations have had their changes over the years, the intentional leak has remained. And as long as Simple MAPI is implemented on top of Extended MAPI, we can't take the leak out. It will even be there in Outlook 2007.

    Mitigation

    If you're using Outlook's MAPI, or any version of Exchange's MAPI prior to Exchange 2003, the best you can do is minimize the number of times you uninitialize MAPI. If you're using Simple MAPI, this means do an explicit MAPILogon/MAPILogoff, and don't do them in a loop. If you're using Extended MAPI, initialize MAPI on your main thread before you do any MAPI work, and wait to uninitialize it until just before your process exits. Subsequent MAPIInitialize/MAPIUninitialize calls on other threads will act like Addref/Release on the MAPI subsystem so they won't incur the leak.

    If you know you'll be using MAPI from Exchange 2003 or from the MAPI download, then you can benefit from the fact that we cut Simple MAPI there. This means we were finally able to put back the code to clean up the heap. It took us a couple times to get it right, but the upshot is that once the hotfix from KB 901014 is applied, you can set the CleanUpMAPIHeap key and no longer worry about this leak.

    Incidentally, the reason we wrapped this fix in a registry key is because before we took this fix, any program which got memory from MAPI, uninitialized MAPI, and then used the memory would not appear to have a problem. But like Simple MAPI, as soon as we start cleaning up the heap, this pattern will cause crashes. So do test carefully before deploying this key!

Page 1 of 1 (3 items)
  • © 2013 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy & Cookies
  • Report Abuse
  • 5.6.426.415