Share via


IShellLibrary ::Save, méthode (shobjidl_core.h)

Enregistre la bibliothèque dans un nouveau fichier Description de la bibliothèque (*.library-ms).

Syntaxe

HRESULT Save(
  [in]  IShellItem       *psiFolderToSaveIn,
  [in]  LPCWSTR          pszLibraryName,
  [in]  LIBRARYSAVEFLAGS lsf,
  [out] IShellItem       **ppsiSavedTo
);

Paramètres

[in] psiFolderToSaveIn

Type : IShellItem*

Objet IShellItem qui spécifie le dossier dans lequel enregistrer la bibliothèque, ou NULL pour enregistrer la bibliothèque avec les bibliothèques par défaut de l’utilisateur dans le FOLDERID_Libraries dossier connu.

[in] pszLibraryName

Type : LPCWSTR

Nom de fichier sous lequel enregistrer la bibliothèque. Le nom de fichier ne doit pas inclure l’extension de nom de fichier ; l’extension de nom de fichier est ajoutée automatiquement.

[in] lsf

Type : LIBRARYSAVEFLAGS

Valeur LIBRARYSAVEFLAGS qui spécifie comment gérer une collision de nom de bibliothèque.

[out] ppsiSavedTo

Type : IShellItem**

Objet IShellItem qui représente le fichier de description de la bibliothèque dans lequel la bibliothèque a été enregistrée.

Valeur retournée

Type : HRESULT

Si cette méthode réussit, elle retourne S_OK. Sinon, elle retourne un code d’erreur HRESULT.

Remarques

IShellLibrary ::Save et SHSaveLibraryInFolderPath créent un fichier de bibliothèque et enregistrez le fichier sur le disque. Pour enregistrer les modifications apportées à une bibliothèque qui a un fichier de bibliothèque existant, appelez IShellLibrary ::Commit.

Si la bibliothèque est enregistrée dans le dossier Bibliothèques connues (FOLDERID_Libraries), l’emplacement de la bibliothèque est automatiquement ajouté à l’index système.

Pour des raisons pratiques, SHSaveLibraryInFolderPath peut être utilisé à la place de cette méthode.

Exemples

L’exemple de code suivant montre la fonction d’assistance SHSaveLibraryInFolderPath, qui encapsule cette méthode.

//
// 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;
}

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 7 [applications de bureau uniquement]
Serveur minimal pris en charge Windows Server 2008 R2 [applications de bureau uniquement]
Plateforme cible Windows
En-tête shobjidl_core.h (inclure Shobjidl.h)

Voir aussi

IShellLibrary

SHSaveLibraryInFolderPath

Bibliothèques Windows