Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Basic issue i got confused help

Basic issue i got confused help

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    monsieur_jj
    wrote on last edited by
    #1

    Hi all, This code below returns a value either "" or "anything" however instead or returning "" it returns -1;

    BSTR* MapiMessageEntity::GetPropUNICODE(LONG PropertyID)
    {
    BSTR* pRetVal;

    pRetVal = 0;
    // make sure the requested property's type is unicode
    if ((PROP\_TYPE\_MASK & PropertyID) != PT\_UNICODE)
    {
    	return 0;
    }
    // find the property
    redmap::mapi::FoundProperty prop 
    	= m\_Message->FindProperty(PropertyID);
    
    if (prop.second)
    {
    	pRetVal = reinterpret\_cast(prop.first.lpszW);
    	return (pRetVal);
    } 
    else 
    {
    	pRetVal = reinterpret\_cast("");
    	return (pRetVal);
    }
    

    }

    The above function is being called by

    strSender = _bstr_t(MapiMessage->GetPropUNICODE(PR_SENDER_NAME_W));

    Why does it return "-1" instead of just "" Thanks, Jj

    N C 2 Replies Last reply
    0
    • M monsieur_jj

      Hi all, This code below returns a value either "" or "anything" however instead or returning "" it returns -1;

      BSTR* MapiMessageEntity::GetPropUNICODE(LONG PropertyID)
      {
      BSTR* pRetVal;

      pRetVal = 0;
      // make sure the requested property's type is unicode
      if ((PROP\_TYPE\_MASK & PropertyID) != PT\_UNICODE)
      {
      	return 0;
      }
      // find the property
      redmap::mapi::FoundProperty prop 
      	= m\_Message->FindProperty(PropertyID);
      
      if (prop.second)
      {
      	pRetVal = reinterpret\_cast(prop.first.lpszW);
      	return (pRetVal);
      } 
      else 
      {
      	pRetVal = reinterpret\_cast("");
      	return (pRetVal);
      }
      

      }

      The above function is being called by

      strSender = _bstr_t(MapiMessage->GetPropUNICODE(PR_SENDER_NAME_W));

      Why does it return "-1" instead of just "" Thanks, Jj

      N Offline
      N Offline
      nbugalia
      wrote on last edited by
      #2

      You are using - return 0; and pRetVal = reinterpret_cast(""); return (pRetVal); I guess both (not sure about the first one) will return "" and not -1; Also the return type is BSTR*. Are you sure it will return numeric values ?

      M 1 Reply Last reply
      0
      • N nbugalia

        You are using - return 0; and pRetVal = reinterpret_cast(""); return (pRetVal); I guess both (not sure about the first one) will return "" and not -1; Also the return type is BSTR*. Are you sure it will return numeric values ?

        M Offline
        M Offline
        monsieur_jj
        wrote on last edited by
        #3

        i removed the return 0 because it is not needed however I am still getting "-1" not "". -1 is enclosed with "". I don't understand why

        M 1 Reply Last reply
        0
        • M monsieur_jj

          i removed the return 0 because it is not needed however I am still getting "-1" not "". -1 is enclosed with "". I don't understand why

          M Offline
          M Offline
          monsieur_jj
          wrote on last edited by
          #4

          Even I get a content example "JJ" it still returns "-1". How is this possible?

          1 Reply Last reply
          0
          • M monsieur_jj

            Hi all, This code below returns a value either "" or "anything" however instead or returning "" it returns -1;

            BSTR* MapiMessageEntity::GetPropUNICODE(LONG PropertyID)
            {
            BSTR* pRetVal;

            pRetVal = 0;
            // make sure the requested property's type is unicode
            if ((PROP\_TYPE\_MASK & PropertyID) != PT\_UNICODE)
            {
            	return 0;
            }
            // find the property
            redmap::mapi::FoundProperty prop 
            	= m\_Message->FindProperty(PropertyID);
            
            if (prop.second)
            {
            	pRetVal = reinterpret\_cast(prop.first.lpszW);
            	return (pRetVal);
            } 
            else 
            {
            	pRetVal = reinterpret\_cast("");
            	return (pRetVal);
            }
            

            }

            The above function is being called by

            strSender = _bstr_t(MapiMessage->GetPropUNICODE(PR_SENDER_NAME_W));

            Why does it return "-1" instead of just "" Thanks, Jj

            C Offline
            C Offline
            carrivick
            wrote on last edited by
            #5

            monsieur_jj wrote:

            pRetVal = reinterpret_cast(prop.first.lpszW);

            This is the line which is in error. Because you are performing a reinterpret_cast it will copy the pointer value but not correctly create the rest of the BSTR class, notably the length which occurs before the string array. My solution would be to change the return type to the WIDE CHAR type the same as lpszW.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups