IWMPError.Item (VB e C#)
[La funzionalità associata a questa pagina, Lettore multimediale Windows SDK, è una funzionalità legacy. È stato sostituito da MediaPlayer. MediaPlayer è stato ottimizzato per Windows 10 e Windows 11. Microsoft consiglia vivamente che il nuovo codice usi MediaPlayer invece di Lettore multimediale Windows SDK, quando possibile. Microsoft suggerisce che il codice esistente che usa le API legacy venga riscritto per usare le nuove API, se possibile.
La proprietà Item (il metodo get_Item in C#) ottiene un'interfaccia IWMPErrorItem in corrispondenza dell'indice specificato nella coda degli errori.
[Visual Basic]
ReadOnly Property Item(
dwIndex As System.Integer
) As IWMPErrorItem
[C#]
IWMPErrorItem get_Item (
System.Int32 dwIndex
);
Parametri
dwIndex
Oggetto System.Int32 che rappresenta l'indice in base zero di un'interfaccia IWMPErrorItem nella coda degli errori.
Valore della proprietà
Interfaccia WMPLib.IWMPErrorItem .
Commenti
Lettore multimediale Windows può generare un numero di errori in risposta a una condizione di errore. Questa proprietà ottiene un errore specifico nella coda usando un numero di indice. I numeri di indice per la coda degli errori iniziano con zero.
È consigliabile impostare IWMPSettings.enableErrorDialogs su false se si sceglie di visualizzare messaggi di errore personalizzati.
Esempio
Nell'esempio seguente viene utilizzata la proprietà Item (il metodo get_Item in C#) in un gestore eventi Error per recuperare e visualizzare informazioni sull'errore più recente nella coda degli errori. L'oggetto AxWMPLib.AxWindowsMediaPlayer è rappresentato dalla variabile denominata 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
Requisiti
Requisito | Valore |
---|---|
Versione |
Lettore multimediale Windows serie 9 o successive |
Spazio dei nomi |
WMPLib |
Assembly |
|
Vedi anche
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per