Persist a pidl (ITEMIDLIST)

前端 未结 3 1845
长情又很酷
长情又很酷 2021-01-12 17:16

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

3条回答
  •  灰色年华
    2021-01-12 17:30

    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.

提交回复
热议问题