Share via


IWMPError::clearErrorQueue 方法

[與此頁面相關聯的功能Windows 媒體播放機 SDK是舊版功能。 它已被 MediaPlayer 取代MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用MediaPlayer,而不是Windows 媒體播放機 SDK。 Microsoft 建議盡可能重寫使用舊版 API 的現有程式碼,以使用新的 API。]

clearErrorQueue方法會清除錯誤佇列中的錯誤。

語法

public void clearErrorQueue();

Public Sub clearErrorQueue()
Implements IWMPError.clearErrorQueue

參數

這個方法沒有任何參數。

傳回值

這個方法不會傳回值。

備註

使用此方法,在處理一系列錯誤之後清除錯誤佇列。

如果您選擇顯示自訂錯誤訊息,您應該將 IWMPSettings.enableErrorDialogs 設定為 false

範例

下列範例會在顯示所有錯誤描述之後,在 Error 事件處理常式中使用 clearErrorQueue 來清空錯誤佇列。 AxWMPLib.AxWindowsMediaPlayer物件是由名為 player 的變數表示。

private void player_ErrorEvent_clearErrorQueue(object sender, System.EventArgs e)
{
    // Store the number of errors in the queue.
    int max = player.Error.errorCount;

    // Loop through the list of errors.
    for (int i = 0; i < max; i++)
    {
        // Get the description for this error.
        string errDesc = player.Error.get_Item(i).errorDescription;

        // Display the error message.
        System.Windows.Forms.MessageBox.Show(errDesc);
    }

    // Clear the error queue to prepare for the next group of errors.
    player.Error.clearErrorQueue();
}

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

    &#39; Store the number of errors in the queue.
    Dim max As Integer = player.Error.errorCount

    &#39; Loop through the list of errors.
    For i As Integer = 0 To (max - 1)

        &#39; Get the description for this error.
        Dim errDesc As String = player.Error.Item(i).errorDescription

        &#39; Display the error message.
        System.Windows.Forms.MessageBox.Show(errDesc)

    Next i

    &#39; Clear the error queue to prepare for the next group of errors.
    player.Error.clearErrorQueue()

End Sub

規格需求

需求
版本
Windows 媒體播放機 9 系列或更新版本
命名空間
WMPLib
組件
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另請參閱

IWMPError 介面 (VB 和 C#)

IWMPSettings.enableErrorDialogs (VB 和 C#)