Share via


IWMDMStorage4::GetParent

banner art

The GetParent method retrieves the parent of the storage.

Syntax

HRESULT GetParent(IWMDMStorage**ppStorage);

Parameters

ppStorage

[out]  Pointer to the IWMDMStorage interface of the parent storage. The caller must release this interface when finished with it.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager can return any of the following classes of error codes:

  • Standard COM error codes
  • Windows error codes converted to HRESULT values
  • Windows Media Device Manager error codes

For an extenstive list of possible error codes, see Error Codes.

Possible values include, but are not limited to, those in the following table. If the method fails with an error, it returns a standard error code.

Return code Description
S_OK The method succeeded and ppStorage holds the IWMDMStorage pointer to the parent object.
S_FALSE Current storage is the root storage and therefore has no parent. In this case, ppStorage is set to NULL.

Remarks

The application can navigate up the storage hierarchy by calling GetParent recursively. After the root storage is reached, GetParent returns S_FALSE and sets ppStorage to NULL.

Example Code

The following C++ function traverses up to the root parent of a storage.

HRESULT BubbleUp(IWMDMStorage *pIStorage)
{
    HRESULT hr = S_OK;
    CComPtr<IWMDMStorage4> pStorage4;

    hr = pIStorage->QueryInterface (__uuidof(IWMDMStorage4), reinterpret_cast<void**>(&pStorage4));
    if (SUCCEEDED(hr))
    {
        while ((pStorage4 != NULL))
        {
            CComPtr<IWMDMStorage> pParent;
            hr = pStorage4->GetParent(&pParent);
            if (FAILED(hr))
            {
                break;
            }

            //
            // Do something with pParent....
            //
            
            if (S_FALSE != hr)
            {
                hr = pParent->QueryInterface (__uuidof(IMDSPStorage4), reinterpret_cast<void**>(&pStorage4));
                if (FAILED(hr))
                {
                    break;
                }
            }
        } // Loop up to next parent.
    }

    return hr;
}

Requirements

Header: Defined in mswmdm.h.

Library: mssachlp.lib

See Also