Basic issue i got confused help
-
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
-
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
-
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 ?
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
-
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
Even I get a content example "JJ" it still returns "-1". How is this possible?
-
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
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.