SHCreateItemInKnownFolder function (shobjidl_core.h)

Creates a Shell item object for a single file that exists inside a known folder.

Syntax

SHSTDAPI SHCreateItemInKnownFolder(
  [in]           REFKNOWNFOLDERID kfid,
                 DWORD            dwKFFlags,
  [in, optional] PCWSTR           pszItem,
  [in]           REFIID           riid,
  [out]          void             **ppv
);

Parameters

[in] kfid

Type: REFKNOWNFOLDERID

A reference to the KNOWNFOLDERID, a GUID that identifies the folder that contains the item.

dwKFFlags

Type: DWORD

Flags that specify special options in the object retrieval. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values.

[in, optional] pszItem

Type: PCWSTR

A pointer to a null-terminated buffer that contains the file name of the new item as a Unicode string. This parameter can also be NULL. In this case, an IShellItem that represents the known folder itself is created.

[in] riid

Type: REFIID

A reference to the IID of the interface that represents the item, retrieved through ppv. This value is typically IID_IShellItem or IID_IShellItem2.

[out] ppv

Type: void**

When this function returns successfully, contains the interface pointer requested in riid. This is typically IShellItem or IShellItem2.

Return value

Type: HRESULT

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

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header shobjidl_core.h (include Shobjidl.h)
DLL Shell32.dll
API set ext-ms-win-shell-shell32-l1-2-0 (introduced in Windows 8.1)

See also

Known Folders Sample