none
Regarding Office 2007 Cached/NonCached mode from ProfileSection RRS feed

  • Question

  • Hi ,

       This below code works fine for Office 2010 and Office 2013. But It fails for Office 2007.

    May I know how to know the cache/noncache mode from the IMapiSession pointer.

    Thanks

    Santhi

     if (FAILED(hr = pSession->lpVtbl->OpenProfileSection(pSession,
           (LPMAPIUID)pbGlobalProfileSectionGuid,
           NULL,
           0L,
           &pGlobalProfSect)))
      goto CleanUp;
     
     hr = pGlobalProfSect->lpVtbl->GetProps(pGlobalProfSect, (LPSPropTagArray) &sPropsProfile, 0, &cValues, &lpPropArray);
     if((S_OK == hr || MAPI_W_ERRORS_RETURNED == hr))
     {
      for(ULONG i = 0; i < cValues; i++)
      {
       LPSPropValue lpSPV = lpPropArray + i;
          // retrieve Profile Name if present
       if(!(lpSPV->ulPropTag ^ PR_PROFILE_NAME))
       {
        m_ProfileName=lpSPV->Value.lpszA;
       }
       else if (PR_PROFILE_CONFIG_FLAGS)
       {
        if (0x180 == (lpSPV->Value.l & 0x180))
         cached = TRUE;
       }
      }
     }

    Thursday, July 18, 2013 1:12 AM

Answers

  • It worked on by changing the code to "((lpSPV->Value.l & 0x180) != 0)" .

    //Works for 2010 and 2013, failed for 2007

    else if (PR_PROFILE_CONFIG_FLAGS)
       {
        if (0x180 == (lpSPV->Value.l & 0x180))
         cached = TRUE;
       }

    //Works for 2007, 2010, 2013.

    else if (lpSPV->ulPropTag == PR_PROFILE_CONFIG_FLAGS)
       {
        cached = ((lpSPV->Value.l & 0x180) != 0) ;

       }

    • Marked as answer by Santhi R Friday, July 19, 2013 1:55 PM
    Friday, July 19, 2013 1:55 PM

All replies

  • What exactly does not work? Is PR_PROFILE_NAME a Unicode or ANSI string property?

    I am not sure what the following line does:

     if(!(lpSPV->ulPropTag ^ PR_PROFILE_NAME))

    did you mean the following?

     if(!(lpSPV->ulPropTag == PR_PROFILE_NAME))

    Also, "if (PR_PROFILE_CONFIG_FLAGS)" is always true.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, July 18, 2013 2:01 AM
  • Hi Dmitry,

     Thanks for your reply.

    I want to know, if 2007 Outlook is running as Cached mode or Non-Cached mode.

    from the below code I could get cached mode or non-cached mode flag for 2010, and 2013. But the if condition never satisfies for Outlook 2007.

     if (FAILED(hr = pSession->lpVtbl->OpenProfileSection(pSession,
            (LPMAPIUID)pbGlobalProfileSectionGuid,
            NULL,
            0L,
            &pGlobalProfSect)))
       goto CleanUp;
     
      hr = pGlobalProfSect->lpVtbl->GetProps(pGlobalProfSect, (LPSPropTagArray) &sPropsProfile, 0, &cValues, &lpPropArray);
      if((S_OK == hr || MAPI_W_ERRORS_RETURNED == hr))
      {
       for(ULONG i = 0; i < cValues; i++)
       {
        LPSPropValue lpSPV = lpPropArray + i;
        if (PR_PROFILE_CONFIG_FLAGS)
         {
              if (0x180 == (lpSPV->Value.l & 0x180))
                     cached = TRUE;
         }
       }
      }

    Thursday, July 18, 2013 1:46 PM
  • Which condition is not satisfied? What is the value of sPropsProfile?

    If you know which properties are requested, why do you need to loop through all of them instead of just using a fixed index when accessing the lpPropArray array?

    Secondly, you code needs to free the returned lpPropArray pointer.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, July 18, 2013 1:51 PM
  • If I use these lines below

    if (lpSPV->ulPropTag == PR_PROFILE_CONFIG_FLAGS) //This is TRUE always,as I requested the correct property
       {
        if (0x180 == (lpSPV->Value.l & 0x180)) //THis never becomes TRUE even though I am in Cached mode

        {     cached = TRUE;

        } 

      }

    Thursday, July 18, 2013 3:08 PM
  • It worked on by changing the code to "((lpSPV->Value.l & 0x180) != 0)" .

    //Works for 2010 and 2013, failed for 2007

    else if (PR_PROFILE_CONFIG_FLAGS)
       {
        if (0x180 == (lpSPV->Value.l & 0x180))
         cached = TRUE;
       }

    //Works for 2007, 2010, 2013.

    else if (lpSPV->ulPropTag == PR_PROFILE_CONFIG_FLAGS)
       {
        cached = ((lpSPV->Value.l & 0x180) != 0) ;

       }

    • Marked as answer by Santhi R Friday, July 19, 2013 1:55 PM
    Friday, July 19, 2013 1:55 PM