Share via


Windows Media Player 11 SDK IWMPMediaCollection2.createQuery (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPMediaCollection2.createQuery (VB and C#)

The createQuery method returns an IWMPQuery interface that represents a new query.

  

Parameters

This method takes 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.

Example Code

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 in order to 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

FakePre-0eabdf3949804e519bcefd8269955a0e-fb47946a516e4df485793e8d29eb43c1

// Get an IWMPMediaCollection2 interface in order to 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));
}

Requirements

Version: Windows Media Player 11.

Namespace: WMPLib

Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)

See Also

Previous Next