SHCreateShellItem function (shlobj_core.h)

Creates an IShellItem object.

Note  It is recommended that you use SHCreateItemWithParent or SHCreateItemFromIDList instead of this function.
 

Syntax

SHSTDAPI SHCreateShellItem(
  [in, optional] PCIDLIST_ABSOLUTE pidlParent,
  [in, optional] IShellFolder      *psfParent,
  [in]           PCUITEMID_CHILD   pidl,
  [out]          IShellItem        **ppsi
);

Parameters

[in, optional] pidlParent

Type: PCIDLIST_ABSOLUTE

A PIDL to the parent. This value can be NULL.

[in, optional] psfParent

Type: IShellFolder*

A pointer to the parent IShellFolder. This value can be NULL.

[in] pidl

Type: PCUITEMID_CHILD

A PIDL to the requested item. If parent information is not included in pidlParent or psfParent, this must be an absolute PIDL.

[out] ppsi

Type: IShellItem**

When this method returns, contains the interface pointer to the new IShellItem.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

SHCreateShellItem creates an object that represents a Shell namespace item. The caller must provide parent information in pidlParent or psfParent; alternatively, the caller can provide an absolute IDList in the pidl parameter.

There are three valid calling patterns for this function:

  1. The parent folder is identified by an absolute IDList pidlParent. The pidl parameter points to a child IDList that identifies the item within the folder identified by pidlParent.
    IShellItem *psi;
    SHCreateShellItem(pidlParent, NULL, pidlChild, &psi);
    
    
  2. The parent folder is identified by psfParent. The pidl parameter points to a child IDList that identifies the item within the folder identified by psfParent.
    IShellItem *psi;
    SHCreateShellItem(NULL, psfParent, pidlChild, &psi);
    
    
  3. The item is identified by an absolute IDList passed to the pidl parameter.
    IShellItem *psi;
    SHCreateShellItem(NULL, NULL, pidlFull, &psi);
    
    

Requirements

Requirement Value
Minimum supported client Windows XP with SP1 [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shlobj_core.h (include Shlobj.h)
Library Shell32.lib
DLL Shell32.dll
API set ext-ms-win-shell-shell32-l1-2-2 (introduced in Windows 10, version 10.0.14393)