HOWTO: Retrieve the PR_PROVIDER_DISPLAY Property

ID: Q181732

The information in this article applies to:

SUMMARY

This article describes how to determine the message store provider name.

MORE INFORMATION

The following code sample illustrates how to retrieve the PR_PROVIDER_DISPLAY property of a given message store. This can be useful in determining the type of information store you are working with.

Here is the code:

   #include <windows.h>
   #include <mapiutil.h>
   // NOTE: You will need to include Mapi32.lib as an additional
   // library in the Link tab of the Project Settings dialog box.

   HRESULT MsgStoreType ( LPMAPISESSION pSession, LPSBinary pMsgStoreID )
   {
      HRESULT         hRes = S_OK;
      LPMAPITABLE     pTable = NULL;
      LPSRowSet       pRows = NULL;
      SRestriction    sRes;
      SPropValue      spvStoreID;

      SizedSPropTagArray ( 2, spta ) =
         { 2, PR_ENTRYID, PR_PROVIDER_DISPLAY };

      ZeroMemory ( &sRes, sizeof ( SRestriction ));

      spvStoreID.ulPropTag = PR_ENTRYID;
      spvStoreID.Value.bin.cb = pMsgStoreID -> cb;
      spvStoreID.Value.bin.lpb = pMsgStoreID -> lpb;

      // Open the message stores table.
      hRes = pSession -> GetMsgStoresTable ( 0l, &pTable ) ) );

      if ( FAILED ( hRes ) )
         goto Cleanup;

      sRes.rt = RES_PROPERTY;
      sRes.res.resProperty.relop = RELOP_EQ;
      sRes.res.resProperty.ulPropTag = PR_ENTRYID;
      sRes.res.resProperty.lpProp = &spvStoreID;

      // Find the row that matches the passed in message store ID.
      hRes = HrQueryAllRows ( pTable,
                            (LPSPropTagArray)&spta,
                            &sRes,
                            NULL,
                            0l,
                            &pRows ) ) )
         goto Cleanup;

      // PR_PROVIDER_DISPLAY is in pRows -> aRow -> lpProps[1].Value.lpszA
      MessageBox ( m_hWnd,
                  pRows -> aRow -> lpProps[1].Value.lpszA,
                  "Information Store",
                  MB_OK );

   Cleanup:

      if ( pTable )
      {
         pTable -> Release ( );
         pTable = NULL;
      }

      if ( pRows )
         FreeProws ( pRows );

      return hRes;
   }

Keywords          : kbcode kbMsg kbMAPI100 MAPIIMS 
Version           : WINDOWS:1.0
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: February 28, 1998