IWMPMediaCollection2::createQuery-Methode
Die createQuery -Methode gibt eine IWMPQuery-Schnittstelle zurück, die eine neue Abfrage darstellt.
Syntax
public IWMPQuery createQuery();
Public Function createQuery() As IWMPQuery
Implements IWMPMediaCollection2.createQuery
Parameter
Diese Methode hat keine Parameter.
Rückgabewert
Eine WMPLib.IWMPQuery-Schnittstelle, die eine neue, leere Abfrage darstellt.
Bemerkungen
Das Erstellen einer neuen Abfrage ist der erste Schritt zum Erstellen einer zusammengesetzten Abfrage.
Beispiele
Im folgenden Beispiel wird createQuery verwendet, um eine IWMPQuery-Schnittstelle zu erhalten, die mit NULL initialisiert wird. Da dieser Abfrage keine Bedingungen hinzugefügt wurden, gibt die Methode eine Zeichenfolgensammlung zurück, die alle Medienelemente des angegebenen Medientyps enthält, wenn sie als Argument in der getStringCollectionByQuery-Methode verwendet wird. Die Zeichenfolgensammlung wird dann in einem Listenfeld angezeigt.
// 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 (Anforderungen)
| Anforderung | Wert |
|---|---|
| Version |
Windows Media Player 11. |
| Namespace |
WMPLib |
| Assembly |
|