IWMDMStorage4::GetParent 方法 (mswmdm.h)
GetParent 方法检索存储的父级。
语法
HRESULT GetParent(
[out] IWMDMStorage **ppStorage
);
参数
[out] ppStorage
指向父存储的 IWMDMStorage 接口的指针。 调用方在完成此接口后必须释放它。
返回值
该方法返回 HRESULT。 Windows Media 设备管理器 中的所有接口方法都可以返回以下任一类错误代码:
- 标准 COM 错误代码
- 转换为 HRESULT 值的 Windows 错误代码
- Windows Media 设备管理器错误代码
注解
应用程序可以通过以递归方式调用 GetParent 来向上导航存储层次结构。 到达根存储后, GetParent 将返回S_FALSE并将 ppStorage 设置为 NULL。
示例
以下 C++ 函数遍历存储的根父级。
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;
}
要求
要求 | 值 |
---|---|
目标平台 | Windows |
标头 | mswmdm.h |
Library | Mssachlp.lib |