I\'d like to persist pidls between sessions, so that my application can remember the users\' folder selections, wherever they may be in the namespace, even if they\'re not f
According to Raymond Chen you can persist a pidl -- or, more specifically, a SHITEMID structure, just by writing out length of the item and then the bytes.
Notice that this struct is a typical Windows variable length struct, with a cb ("count of bytes") element specifying the length of the structure in bytes, followed by the rest of the data. In other words, to write the structure, you need to write cb bytes. To read it, you need to allocated cb bytes of memory and set the cb field.
Be careful not to use sizeof(SHITEMID) because the way it's declared assumes only one byte for the abID field so that won't be big enough.