IShellLibrary::AddFolder method (shobjidl_core.h)

Adds a folder to the library.

Syntax

HRESULT AddFolder(
  [in] IShellItem *psiLocation
);

Parameters

[in] psiLocation

Type: IShellItem*

An IShellItem object that represents the folder to be added to the library.

Return value

Type: HRESULT

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

Remarks

When a folder is added to a library it is also added to the Windows Search index.

For convenience, SHAddFolderPathToLibrary can be used in place of this method.

Examples

The following code example shows the helper function SHAddFolderPathToLibrary, which wraps this method.

//
// From Shobjidl.h
//
__inline HRESULT SHAddFolderPathToLibrary (
    __in IShellLibrary *plib,
    __in PCWSTR pszFolderPath
)
{
    IShellItem *psiFolder;
    
    HRESULT hr = SHCreateItemFromParsingName (
      pszFolderPath, 
      NULL,
      IID_PPV_ARGS(&psiFolder));
    
    if (SUCCEEDED(hr))
    {
        hr = plib->AddFolder (psiFolder);
        psiFolder->Release ();
    }
    return hr;
}

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header shobjidl_core.h (include Shobjidl.h)

See also

IShellLibrary

IShellLibrary::LoadLibraryFromItem

IShellLibrary::LoadLibraryFromKnownFolder

IShellLibrary::RemoveFolder

Library Description Schema

SHAddFolderPathToLibrary

SHLoadLibraryFromItem

SHLoadLibraryFromKnownFolder

SHLoadLibraryFromParsingName

SHRemoveFolderPathFromLibrary

Windows Libraries