This project is read-only.

Problem with named properties map

Oct 10, 2011 at 5:26 PM

I have noticed an oddity when doing work with named properties.  I have
code that looks something like this:

pstsdk::name_id_map *gNamedProps;

if (gNamedProps->prop_id_exists(nprop))
  newprop = gNamedProps->lookup(PS_CONTACTS, nprop);

mstr = bag.read_prop<wstring>(newprop);

The problem is that sometimes gNamedProps->prop_id_exists() returns
FALSE even though the named property ID does in fact exist.  An example
would be ID x8208 (location) in a calendar object.  This is supposed to
map to property x8021, and in fact, if I just skip over prop_id_exist()
and go right to the lookup, I do get back 8021.  In another test,
If I try ID x8083 (Email1Address) in the contacts object, this *does* return
TRUE for prop_id_exists().  I do need to to a validity check on the ID
value that I pass into lookup() in order to avoid a crash.  I have managed to
work around the problem by putting the lookup() call inside try/catch.  But
can you comment on whether I am doing something wrong or is this a bug in
the SDK?



Oct 12, 2011 at 6:00 AM

The parameter to prop_id_exists is a prop_id (the thing that a named prop maps to). If you look at the implementation of this function in nameid.h, you'll see it's pretty simple - because the PST assigns prop_ids sequentially. 

You're passing in the an id for a named prop (half of a name_id pair, the other half being a GUID - PS_CONTACTS). 

So, you're using the same value two different ways. prop_id_exists takes the "value" part of it. Lookup takes the "key".