IWMPMediaCollection2::createQuery 方法
该方法 createQuery
返回一个表示新查询的 IWMPQuery 接口。
语法
public IWMPQuery createQuery();
Public Function createQuery() As IWMPQuery
Implements IWMPMediaCollection2.createQuery
parameters
此方法没有任何参数。
返回值
一个 WMPLib.IWMPQuery 接口,表示新的空查询。
注解
创建新查询是创建复合查询的第一步。
示例
以下示例用于 createQuery
获取初始化为 null 的 IWMPQuery 接口。 由于此查询未添加任何条件,因此当它用作 getStringCollectionByQuery 方法中的参数时,该方法将返回包含指定媒体类型的所有媒体项的字符串集合。 然后,字符串集合将显示在列表框中。
// Get an IWMPMediaCollection2 interface so that you can access the createQuery and
// getStringCollectionByQuery methods.
WMPLib.IWMPMediaCollection2 mc = (WMPLib.IWMPMediaCollection2)player.mediaCollection;
// Create an IWMPQuery interface with no conditions added to it.
WMPLib.IWMPQuery nullQuery = mc.createQuery();
// Get a string collection that contains the titles of all the audio items in the media
// collection.
WMPLib.IWMPStringCollection2 allTitles = (WMPLib.IWMPStringCollection2)mc.getStringCollectionByQuery("Title", nullQuery, "audio", "", false);
// Display the titles by adding them to a list box.
for (int i = 0; i < allTitles.count; i++)
{
queryResults.Items.Add(allTitles.Item(i));
}
' Get an IWMPMediaCollection2 interface so that you can access
' the createQuery and getStringCollectionByQuery methods.
Dim mc As WMPLib.IWMPMediaCollection2 = player.mediaCollection
' Create an IWMPQuery interface with no conditions added to it.
Dim nullQuery As WMPLib.IWMPQuery = mc.createQuery()
' Get a string collection that contains the titles of all the audio items in the media
' collection
Dim allTitles As WMPLib.IWMPStringCollection2 = mc.getStringCollectionByQuery("Title", nullQuery, "audio", "", False)
' Display the titles by adding them to a ListBox
For i As Integer = 0 To (allTitles.count - 1)
queryResults.Items.Add(allTitles.Item(i))
Next i
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 11. |
命名空间 |
WMPLib |
Assembly |
|