IWMPMediaCollection::remove 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
方法 remove
从媒体集合中删除指定的项。
语法
public void remove(
IWMPMedia pItem,
System.Boolean varfDeleteFile
);
Public Sub remove( _
ByVal pItem As IWMPMedia, _
ByVal varfDeleteFile As System.Boolean _
)
Implements IWMPMediaCollection.remove
参数
-
pItem [in]
-
标识要删除的项的 WMPLib.IWMPMedia 接口。
-
varfDeleteFile [in]
-
一个 System.Boolean 值,该值指定方法是否应从库中删除指定的项。
返回值
此方法不返回值。
备注
此方法从库中删除项。 此方法不会从用户的计算机中删除文件。
在调用此方法之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
以下示例在提示用户后,使用 remove
永久删除媒体集合中的第一个媒体项。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Get an interface to the first item from the media collection.
WMPLib.IWMPMedia3 media = (WMPLib.IWMPMedia3)player.mediaCollection.getAll().get_Item(0);
// Store the name of the retrieved media item.
string mediaName = media.name;
// Prepare a message, a caption and buttons for the user prompt.
string message = ("OK to permanently delete " + mediaName + "?");
string caption = "Confirm deletion";
System.Windows.Forms.MessageBoxButtons buttons = System.Windows.Forms.MessageBoxButtons.OKCancel;
// Prompt the user for permission to delete the object.
System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
// Check the user response.
if (result == System.Windows.Forms.DialogResult.OK)
{
// Permanently delete the item.
player.mediaCollection.remove(media, true);
// Report that the item was deleted.
System.Windows.Forms.MessageBox.Show("Deleted item " + mediaName);
}
' Get an interface to the first item from the media collection.
Dim media As WMPLib.IWMPMedia3 = player.mediaCollection.getAll().Item(0)
' Store the name of the retrieved media item.
Dim mediaName As String = media.name
' Prepare a message, a caption and buttons for the user prompt.
Dim message As String = ("OK to permanently delete " + mediaName + "?")
Dim caption As String = "Confirm deletion"
Dim buttons As System.Windows.Forms.MessageBoxButtons = System.Windows.Forms.MessageBoxButtons.OKCancel
' Prompt the user for permission to delete the object.
Dim result As System.Windows.Forms.DialogResult = System.Windows.Forms.MessageBox.Show(message, caption, buttons)
' Check the user response.
If (result = System.Windows.Forms.DialogResult.OK) Then
' Permanently delete the item.
player.mediaCollection.remove(media, True)
' Report that the item was deleted.
System.Windows.Forms.MessageBox.Show("Deleted item " + mediaName)
End If
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈