Skip to content

Latest commit

 

History

History
155 lines (115 loc) · 5.13 KB

nf-shobjidl_core-ishelllibrary-save.md

File metadata and controls

155 lines (115 loc) · 5.13 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:shobjidl_core.IShellLibrary.Save
IShellLibrary::Save (shobjidl_core.h)
Saves the library to a new Library Description (*.library-ms) file.
IShellLibrary interface [Windows Shell]
Save method
IShellLibrary.Save
IShellLibrary::Save
Save
Save method [Windows Shell]
Save method [Windows Shell]
IShellLibrary interface
_shell_IShellLibrary_Save
shell.IShellLibrary_Save
shobjidl_core/IShellLibrary::Save
shell\IShellLibrary_Save.htm
shell
2a7de829-f0bc-4ace-aed4-83d0611ae292
12/05/2018
IShellLibrary interface [Windows Shell],Save method, IShellLibrary.Save, IShellLibrary::Save, Save, Save method [Windows Shell], Save method [Windows Shell],IShellLibrary interface, _shell_IShellLibrary_Save, shell.IShellLibrary_Save, shobjidl_core/IShellLibrary::Save
shobjidl_core.h
Shobjidl.h
Windows
Windows 7 [desktop apps only]
Windows Server 2008 R2 [desktop apps only]
Shobjidl.idl
Windows
19H1
IShellLibrary::Save
shobjidl_core/IShellLibrary::Save
c++
APIRef
kbSyntax
COM
shobjidl_core.h
IShellLibrary.Save

IShellLibrary::Save

-description

Saves the library to a new Library Description (*.library-ms) file.

-parameters

-param psiFolderToSaveIn [in]

Type: IShellItem*

The IShellItem object that specifies the folder in which to save the library, or NULL to save the library with the user's default libraries in the FOLDERID_Libraries known folder.

-param pszLibraryName [in]

Type: LPCWSTR

The file name under which to save the library. The file name must not include the file name extension; the file name extension is added automatically.

-param lsf [in]

Type: LIBRARYSAVEFLAGS

The LIBRARYSAVEFLAGS value that specifies how to handle a library name collision.

-param ppsiSavedTo [out]

Type: IShellItem**

The IShellItem object that represents the library description file into which the library was saved.

-returns

Type: HRESULT

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

-remarks

IShellLibrary::Save and SHSaveLibraryInFolderPath create a new library file, and save the file to disk. To save changes made to a library that has an existing library file, call IShellLibrary::Commit.

If the library is saved in the Libraries known folder (FOLDERID_Libraries), the library's location is automatically added to the system index.

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

Examples

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

//
// from shobjidl.h
//
__inline HRESULT SHSaveLibraryInFolderPath(
    __in IShellLibrary *plib, 
    __in PCWSTR pszFolderPath, 
    __in PCWSTR pszLibraryName, 
    __in LIBRARYSAVEFLAGS lsf, 
    __deref_opt_out PWSTR *ppszSavedToPath
)
{
    if (ppszSavedToPath)
    {
        *ppszSavedToPath = NULL;
    }

    IShellItem *psiFolder;
    HRESULT hr = SHCreateItemFromParsingName(
      pszFolderPath, 
      NULL, 
      IID_PPV_ARGS(&psiFolder));

    if (SUCCEEDED(hr))
    {
        IShellItem *psiSavedTo;
        hr = plib->Save(psiFolder, pszLibraryName, lsf, &psiSavedTo);

        if (SUCCEEDED(hr))
        {
            if (ppszSavedToPath)
            {
                hr = psiSavedTo->GetDisplayName(
                  SIGDN_DESKTOPABSOLUTEPARSING, 
                  ppszSavedToPath);
            }
            psiSavedTo->Release();
        }
        psiFolder->Release();
    }
    return hr;
}

-see-also

IShellLibrary

SHSaveLibraryInFolderPath

Windows Libraries