FILE: Mapiasst.exe: MAPI ASSERT Debug Routines

ID: Q177542

The information in this article applies to:

SUMMARY

This sample consists of a header file that provides debugging routines to assist developers of messaging applications.

MORE INFORMATION

The following file is available for download from the Microsoft Software Library:

 ~ Mapiasst.exe (size: 29184 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

The Mapiasst.exe sample, contains the following two files: The header file, Mapiasst.h, was written to assist messaging developers in writing and debugging their applications.

Mapiasst.h includes the following three debug macros:

MAPI_ASSERT(HRESULT)

Pass MAPI_ASSERT a HRESULT and MAPI_ASSERT gives you basic error output and returns you to the debugger at the point where the error occurred.

Sample Output:

   **ASSERT! File : C:\Srccode\MsgStores\Main.Cpp
        Line : 29
        Value : 0x80040111

MAPI_ASSERT_EX(HRESULT)

MAPI_ASSERT_EX works similar to MAPI_ASSERT and gives you the same information along with the meaning of the HRESULT error code. Again, you will be returned back to the debugger at the point of error.

Sample Output:

   **ASSERT! File : C:\Srccode\MsgStores\Main.Cpp
        Line : 29
        Value : 0x80040111
      Meaning : MAPI_E_LOGON_FAILED

SHOWTABLE(LPMAPITABLE)

SHOWTABLE uses the Tblvu32.dll function ViewMapiTable() to display the passed in MAPITable (LPMAPITABLE) in a GUI dialog box. This is a good tool for debugging your MAPITables.

NOTE: Tblvu32.dll is available from the Microsoft FTP site at ftp.microsoft.com\Developr\Mapi\Samples\Mfcapps.zip)

Here is a short sample of how these debugging routines may be used:

   /////// MAIN.CPP //////// 
   void main()
   {
     HRESULT         hr            = S_OK;
     LPMAPISESSION   lpSession      = NULL;
     LPMAPITABLE      lptMsgStores   = NULL;

     // Init MAPI
     hr = MAPIInitialize(0);

     MAPI_ASSERT_EX(hr);

     // Logon to Extended MAPI session
     hr = MAPILogonEx((ULONG)GetActiveWindow(),
               //"OFFLINE"
               NULL,
               NULL,
               NULL,
               &lpSession);

     MAPI_ASSERT_EX(hr);

     // Get a table of Message Stores from the Session.
     hr = lpSession->GetMsgStoresTable(NULL, &lptMsgStores);

     SHOWTABLE(lptMsgStores);

     MAPI_ASSERT_EX(hr);
   }

Additional query words: ASSERT MAPI SHOWTABLE MAPI_ASSERT MAPI_ASSERT_EX debug Table Tables
Keywords          : kbcode kbfile kbMAPI kbMsg kbEDK400 kbEDK500 kbMAPI000 kbMAPI100 
Version           : WINDOWS:1.0,4.0,5.0
Platform          : WINDOWS

Last Reviewed: March 16, 1999