StgCreatePropSetStg, fonction (coml2api.h)

La fonction StgCreatePropSetStg crée un objet de stockage de jeu de propriétés à partir d’un objet de stockage spécifié. L’objet de stockage du jeu de propriétés fournit l’implémentation autonome fournie par le système de l’interface IPropertySetStorage .

Syntaxe

HRESULT StgCreatePropSetStg(
  [in]  IStorage            *pStorage,
        DWORD               dwReserved,
  [out] IPropertySetStorage **ppPropSetStg
);

Paramètres

[in] pStorage

Pointeur vers l’objet de stockage qui contient ou contiendra un ou plusieurs jeux de propriétés.

dwReserved

Réservé pour une future utilisation ; doit être nul.

[out] ppPropSetStg

Pointeur vers la variable de pointeur IPropertySetStorage* qui reçoit le pointeur d’interface vers l’objet de stockage de jeu de propriétés.

Valeur retournée

Cette fonction prend en charge la valeur de retour standard E_INVALIDARG ainsi que les éléments suivants :

Remarques

La fonction StgCreatePropSetStg crée une interface IPropertySetStorage qui agit sur l’interface IStorage spécifiée par le paramètre pStorage . Cette fonction ne modifie pas cet IStorage d’elle-même, bien que les appels suivants à l’interface IPropertySetStorage puissent le faire.

StgCreatePropSetStg appelle IUnknown ::AddRef sur l’objet de stockage spécifié par pStorage. L’appelant doit libérer l’objet lorsqu’il n’est plus nécessaire en appelant Release.

Exemples

L’exemple de code suivant montre comment cette fonction crée un jeu de propriétés dans un objet de stockage.

IPropertyStorage*
CreatePropertySetInStorage( IStorage *pStg, const FMTID &fmtid )
{
    HRESULT hr = S_OK;
    IPropertySetStorage *pPropSetStg = NULL;
    IPropertyStorage *pPropStg = NULL;
 
    try
    {
        hr = StgCreatePropSetStg( pStg, 0, &pPropSetStg );
        if( FAILED(hr) ) throw L"Failed StgCreatePropSetStg (%08x)";
 
        hr = pPropSetStg->Create( fmtid, NULL,
            PROPSETFLAG_DEFAULT,
            STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
            &pPropStg );
        if( FAILED(hr) ) 
            throw L"Failed IPropertySetStorage::Create (%08x)";
 
        // Success. The caller must now call Release on both
        // pPropSetStg and pStg.
 
    }
    catch( const WCHAR *pwszError )
    {
        wprintf( L"Error: %s (%08x)\n", pwszError, hr );
    }
 
    if( NULL != pPropSetStg )
        pPropSetStg->Release();
 
    return( pPropStg );
}

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 2000 Professionnel [applications de bureau | Applications UWP]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau | Applications UWP]
Plateforme cible Windows
En-tête coml2api.h (include Propidl.h)
Bibliothèque Ole32.lib
DLL Ole32.dll

Voir aussi

Implémentation autonome IPropertySetStorage

Exemples

Exemple StgCreatePropSetStg