IWMPError.Item (VB and C#)

The Item property (the get_Item method in C#) gets an IWMPErrorItem interface at the specified index in the error queue.

[Visual Basic]
ReadOnly Property Item(
  dwIndex As System.Integer
) As IWMPErrorItem
[C#]
IWMPErrorItem get_Item (
  System.Int32 dwIndex
);

Parameters

dwIndex

A System.Int32 that is the zero-based index of an IWMPErrorItem interface in the error queue.

Property Value

A WMPLib.IWMPErrorItem interface.

Remarks

Windows Media Player can generate a number of errors in response to an error condition. This property gets a specific error in the queue by using an index number. The index numbers for the error queue begin with zero.

You should set IWMPSettings.enableErrorDialogs to false if you choose to display custom error messages.

Examples

The following example uses the Item property (the get_Item method in C#) in an Error event handler to retrieve and display information about the most recent error in the error queue. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

private void player_ErrorEvent_get_Item(object sender, System.EventArgs e)
{
    // Store the index of the most recent error.
    int max = (player.Error.errorCount - 1);

    // Get an interface for the most recent error item. Cast it to
    // a WMPLib.IWMPErrorItem2 interface to get all of the available functionality.
    WMPLib.IWMPErrorItem2 errItem = (WMPLib.IWMPErrorItem2)player.Error.get_Item(max);

    // Use the interface to access and store the error info.
    int errNum = errItem.errorCode;
    string errDesc = errItem.errorDescription;

    // Display the error info.
    System.Windows.Forms.MessageBox.Show(errNum.ToString() + ":  " + errDesc);
}

Public Sub player_ErrorEvent_get_Item(ByVal sender As Object, ByVal e As System.EventArgs) Handles player.ErrorEvent

    ' Store the index of the most recent error.
    Dim max As Integer = (player.Error.errorCount - 1)

    ' Get an interface for the most recent error item. 
    Dim errItem As WMPLib.IWMPErrorItem2 = player.Error.Item(max)

    ' Use the interface to access and store the error info.
    Dim errNum As Integer = errItem.errorCode
    Dim errDesc As String = errItem.errorDescription

    ' Display the error info.
    System.Windows.Forms.MessageBox.Show(errNum.ToString() + ":  " + errDesc)

End Sub

Requirements

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

See also

IWMPError Interface (VB and C#)

IWMPErrorItem Interface (VB and C#)

IWMPSettings.enableErrorDialogs (VB and C#)