IWMDMEnumStorage::Next メソッド (mswmdm.h)
Next メソッドは、次の兄弟ストレージへのポインターを取得します。
構文
HRESULT Next(
[in] ULONG celt,
[out] IWMDMStorage **ppStorage,
[out] ULONG *pceltFetched
);
パラメーター
[in] celt
要求されたストレージの数。
[out] ppStorage
IWMDMStorage インターフェイス ポインターの呼び出し元によって割り当てられた配列へのポインター。 この配列のサイズは IWMDMStorage *[celt]である必要があります。 呼び出し元は、これらのインターフェイスが完了したら、これらのインターフェイスを解放する必要があります。 配列全体の割り当てを回避するには、「備考」に示すように、ポインターのアドレスを IWMDMStorage インターフェイスに渡します。
[out] pceltFetched
列挙されたストレージの数。
戻り値
このメソッドは HRESULT を返します。 Windows Media デバイス マネージャーのすべてのインターフェイス メソッドは、次のいずれかのエラー コード クラスを返すことができます。
- 標準 COM エラー コード
- HRESULT 値に変換された Windows エラー コード
- Windows Media デバイス マネージャー エラー コード
注釈
Windows Media デバイス マネージャーは、ストレージ列挙を対応するサービス プロバイダーに委任します。 サービス プロバイダーストレージ列挙の詳細については、 IMDSPEnumStorage インターフェイスを参照してください。
記憶域列挙子は、メディアの挿入と削除の影響を反映していない可能性があります。 その場合、アプリケーションは IWMDMDevice::EnumStorage を呼び出して新しいストレージ列挙子オブジェクトを取得し、更新されたリストを取得する必要があります。 一度に 1 つのインターフェイスのみを取得する場合は、次のコードに示すように、このメソッドの配列を割り当てる必要はありません。
例
次の 2 つの C++ 関数は、デバイスを再帰的に探索します。 1 つ目は、ルート デバイス ストレージの IWMDMEnumStorage インターフェイスを取得するキックオフ関数です。 これは、入れ子になったすべての関数を調べる再帰関数に渡されます。
// Kickoff function to explore a device.
void ExploreDevice(IWMDMDevice* pDevice)
{
HRESULT hr = S_OK;
// Get a root enumerator.
CComPtr<IWMDMEnumStorage> pEnumStorage;
hr = pDevice->EnumStorage(&pEnumStorage);
RecursiveExploreStorage(pEnumStorage);
HANDLE_HR(hr, "Got a root storage in ExploreDevice.","Couldn't get a root storage in ExploreDevice.");
e_Exit:
return;
}
void RecursiveExploreStorage(IWMDMEnumStorage* pEnumStorage)
{
HRESULT hr = S_OK;
CComPtr<IWMDMStorage> pStorage;
ULONG numRetrieved = 0;
// Loop through all storages in the current storage.
// We don't need to allocate an array to retrieve one
// interface at a time.
while(pEnumStorage->Next(1, &pStorage, &numRetrieved) == S_OK && numRetrieved == 1)
{
// Get the name of the object. The first time this is called on a
// device, it will retrieve '\' as the root folder name.
const UINT MAX_LEN = 255;
WCHAR name[MAX_LEN];
hr = pStorage->GetName((LPWSTR)&name, MAX_LEN);
// TODO: Display the storage name.
// Get metadata for the storage.
if (SUCCEEDED(hr))
GetMetadata(pStorage);
// Find out something about the item.
DWORD attributes = 0;
_WAVEFORMATEX audioFormat;
hr = pStorage->GetAttributes(&attributes, &audioFormat);
HANDLE_HR(hr, "Got storage attributes in RecursivelyExploreStorage.","Couldn't get storage attributes in RecursivelyExploreStorage.");
// If this is a folder, recurse into it.
if (attributes & WMDM_FILE_ATTR_FILE)
// TODO: Display a message indicating that this is a file.
if (attributes & WMDM_FILE_ATTR_FOLDER)
{
// TODO: Display a message indicating that this is a folder.
CComPtr<IWMDMEnumStorage> pEnumSubStorage;
hr = pStorage->EnumStorage(&pEnumSubStorage);
RecursiveExploreStorage(pEnumSubStorage);
}
// Some other useful attributes to check include:
// WMDM_FILE_ATTR_CANDELETE and WMDM_FILE_ATTR_CANPLAY and others to determine what can be done with a storage.
// WMDM_FILE_ATTR_HIDDEN and other attributes to determine display characteristics,
// WMDM_STORAGE_IS_DEFAULT to see if this is the default save location for new files.
pStorage.Release();
} // Get the next storage pointer.
e_Exit:
return;
}
要件
要件 | 値 |
---|---|
対象プラットフォーム | Windows |
ヘッダー | mswmdm.h |
Library | Mssachlp.lib |