IWMPError.Item (VB 和 C#)

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

Item 属性 (C# 中的 get_Item 方法) 获取错误队列中指定索引处的 IWMPErrorItem 接口。

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

parameters

dwIndex

一个 System.Int32 ,它是错误队列中 IWMPErrorItem 接口的从零开始的索引。

属性值

WMPLib.IWMPErrorItem 接口。

备注

Windows 媒体播放器可能会生成大量错误以响应错误条件。 此属性使用索引号获取队列中的特定错误。 错误队列的索引号以零开头。

如果选择显示自定义错误消息,则应将 IWMPSettings.enableErrorDialogs 设置为 false

示例

以下示例在 Error 事件处理程序中使用 Item 属性 (C#) get_Item 方法检索 和显示有关错误队列中最新错误的信息。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 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

要求

要求
版本
Windows 媒体播放器 9 系列或更高版本
命名空间
WMPLib
程序集
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另请参阅

IWMPError 接口 (VB 和 C#)

IWMPErrorItem 接口 (VB 和 C#)

IWMPSettings.enableErrorDialogs (VB 和 C#)