Creating an IShellItem instance for a non-existent

2019-04-02 08:18发布

问题:

How can I get an IShellItem object for a non-existent file (or directory)?

  • SHCreateItemFromParsingName and SHCreateItemFromRelativeName fail with 0x80070002 (file not found) and
  • ILCreateFromPath returns a NULL pidl.

First I thought it might be impossible, but for example IFileSaveDialog creates such an IShellItem for its result (if you specify a new file in the dialog).

回答1:

There is such a thing as a simple pidl and they can represent non-existent files. So I guess you want SHSimpleIDListFromPath and SHCreateItemFromIDList