Partager via


IWMPMediaCollection::setDeleted 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 setDeleted method moves the specified media item to the deleted items folder.

Syntax

public void setDeleted(
  IWMPMedia pItem,
  System.Boolean varfIsDeleted
);

Public Sub setDeleted( _
  ByVal pItem As IWMPMedia, _
  ByVal varfIsDeleted As System.Boolean _
)
Implements IWMPMediaCollection.setDeleted

Parameters

pItem [in]

A WMPLib.IWMPMedia interface for the item to be moved.

varfIsDeleted [in]

A System.Boolean value that specifies whether the item should be moved to the deleted items folder. This value must always be true.

Return value

This method does not return a value.

Remarks

This method does not remove files from the user's computer, it just moves them to the deleted items folder.

Before calling this method, you must have read access to the library. For more information, see Library Access.

Examples

The following example uses setDeleted to move a particular media item to the deleted items folder. The isDeleted method first tests whether the item has already been deleted. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

// Test whether the media item has already been deleted.
if (!player.mediaCollection.isDeleted(media))
{
    // The item is available to be deleted; move it to the deleted items folder.
    player.mediaCollection.setDeleted(media, true);

    // Inform the user that the operation succeeded.
    System.Windows.Forms.MessageBox.Show("Item moved to deleted items folder.");
}
else
{
    // Tell the user the operation is unnecessary.
    System.Windows.Forms.MessageBox.Show("Item is already deleted!");
}

' Test whether the media item has already been deleted.
If (Not player.mediaCollection.isDeleted(media)) Then

    ' The item is available to be deleted move it to the deleted items folder.
    player.mediaCollection.setDeleted(media, True)

    ' Inform the user that the operation succeeded.
    System.Windows.Forms.MessageBox.Show("Item moved to deleted items folder.")

Else

    ' Tell the user the operation is unnecessary.
    System.Windows.Forms.MessageBox.Show("Item is already deleted!")

End If

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

See also

IWMPMedia Interface (VB and C#)

IWMPMediaCollection Interface (VB and C#)