StgCreatePropSetStg 函式 (coml2api.h)

StgCreatePropSetStg 函式會從指定的儲存物件建立屬性集儲存物件。 屬性集儲存物件會提供 IPropertySetStorage 介面的系統提供的獨立實作。

語法

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

參數

[in] pStorage

包含或的儲存物件指標會包含一或多個屬性集。

dwReserved

保留以備將來之用;必須為零。

[out] ppPropSetStg

IPropertySetStorage* 指標變數的指標,可接收屬性集儲存物件的介面指標。

傳回值

此函式支援標準傳回值 E_INVALIDARG ,以及下列專案:

備註

StgCreatePropSetStg 函式會建立 IPropertySetStorage 介面,該介面會針對 pStorage 參數所指定的 IStorage 介面採取行動。 雖然後續對 IPropertySetStorage 介面的呼叫可能會修改此 IStorage,但此函式本身不會修改此 IStorage

StgCreatePropSetStg 會在 pStorage 所指定的記憶體物件上呼叫 IUnknown::AddRef。 呼叫端必須在呼叫 Release 不再需要物件時釋放物件。

範例

下列範例程式代碼示範此函式如何在記憶體物件內建立屬性集。

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

規格需求

需求
最低支援的用戶端 Windows 2000 專業版 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows 2000 Server [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 coml2api.h (包含 Propidl.h)
程式庫 Ole32.lib
Dll Ole32.dll

另請參閱

IPropertySetStorage-獨立實作

範例

StgCreatePropSetStg 範例