Persist a pidl (ITEMIDLIST)

前端 未结 3 1815
长情又很酷
长情又很酷 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:45

    There isn't standard on the internal of pidls. After all, pidl is only used to locate items. As long as the pidl is recognized (or fail predictably) by the PIDL generator & resolver (Windows Explorer or third party shell namespace extensions), Explorer.exe is happy. Nobody says a PIDL must be persistable across machine reboots or user desktops.

    In one case you can make an educated guess if the pidl is persistable across machine reboots is to check the SFGAO_CANLINK attribute. By declaring this attribute, the PIDL resolver declares you can drag an item in the folder to create a desktop shortcut which contains the PIDL of the item. The resolver must handle persistence and backward compatibility in the PIDL otherwise double clicking the shortcut would crash the Explorer process. Buggy programming happens so don't take this for granted.

    In the dark old days pidl are just persisted in byte arrays, or when passing across COM objects are needed, passed in VARIANT as safe arrays of bytes.

提交回复
热议问题