IWMPMediaCollection2::createQuery method

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
&#39; the createQuery and getStringCollectionByQuery methods.
Dim mc As WMPLib.IWMPMediaCollection2 = player.mediaCollection

&#39; Create an IWMPQuery interface with no conditions added to it.
Dim nullQuery As WMPLib.IWMPQuery = mc.createQuery()

&#39; Get a string collection that contains the titles of all the audio items in the media
&#39; collection
Dim allTitles As WMPLib.IWMPStringCollection2 = mc.getStringCollectionByQuery(&quot;Title&quot;, nullQuery, &quot;audio&quot;, &quot;&quot;, False)

&#39; 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

Version
Windows Media Player 11.
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

See also

IWMPMediaCollection2 Interface (VB and C#)

IWMPQuery Interface (VB and C#)