IWMPMediaCollection2::createQuery method
[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
The createQuery
method returns an IWMPQuery interface that represents a new query.
Syntax
public IWMPQuery createQuery();
Public Function createQuery() As IWMPQuery
Implements IWMPMediaCollection2.createQuery
Parameters
This method has no parameters.
Return value
A WMPLib.IWMPQuery interface that represents a new, empty query.
Remarks
Creating a new query is the first step toward creating a compound query.
Examples
The following example uses createQuery
to get an IWMPQuery interface that is initialized to null. Because this query has no conditions added to it, when it is used as an argument in the getStringCollectionByQuery method, the method will return a string collection that contains all of the media items of the specified media type. The string collection is then displayed in a list box.
// 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
Requirements
Requirement | Value |
---|---|
Version |
Windows Media Player 11. |
Namespace |
WMPLib |
Assembly |
|