Search code examples
windowswinapiwindows-shell

How to retrieve creation date of an IShellItem?


I have the pidl of a folder (that may exist or have been deleted).

I can get an IShellItem with the following code, but what I need is to get the Creation date of that folder. I presume I can get it with PKEY_DateCreated, but I don't know how.

SHCreateShellItem(nil, nil, pidl, ShellItem);

How do I do this ?

I use Delphi.


Solution

  • If you have a PIDL you can use SHGetDataFromIDList to get the basic attributes of the object; you don't need IShellItem (or IShellItem2) at all. You would specify SHGDFIL_FINDDATA for the nFormat parameter (see SHGetDataFromIDList🕗 for details).

    The nice thing about this is that for standard filesystem objects the metadata is encoded in the PIDL itself so the function will return useful data even if the object no longer exists.