SHCreateShellItem function

Creates an IShellItem object.

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

Syntax

SHSTDAPI SHCreateShellItem(
  PCIDLIST_ABSOLUTE pidlParent,
  IShellFolder      *psfParent,
  PCUITEMID_CHILD   pidl,
  IShellItem        **ppsi
);

Parameters

pidlParent

Type: PCIDLIST_ABSOLUTE

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

psfParent

Type: IShellFolder*

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

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.

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.
                        <div class="code"><span codelanguage="ManagedCPlusPlus"><table>
    
    C++
    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.
                        <div class="code"><span codelanguage="ManagedCPlusPlus"><table>
    
    C++
    IShellItem *psi;
    SHCreateShellItem(NULL, psfParent, pidlChild, &psi);
    
  3. The item is identified by an absolute IDList passed to the pidl parameter.
                        <div class="code"><span codelanguage="ManagedCPlusPlus"><table>
    
    C++
    IShellItem *psi;
    SHCreateShellItem(NULL, NULL, pidlFull, &psi);
    

Requirements

   
Windows version Windows XP with SP1 [desktop apps only] Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shlobj_core.h (include Shlobj.h)
Library Shell32.lib
DLL Shell32.dll