IWMPCdromCollection::Item 方法

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

Item 方法返回给定索引处的 IWMPCdrom 接口。

语法

public IWMPCdrom Item(
  System.Int32 lIndex
);

Public Function Item( _
  ByVal lIndex As System.Int32 _
) As IWMPCdrom
Implements IWMPCdromCollection.Item

parameters

lIndex [in]

作为索引的 System.Int32

返回值

WMPLib.IWMPCdrom 接口。

注解

若要使用此方法,需要对库的读取访问权限。 有关详细信息,请参阅 库访问

示例

以下示例使用 Item 在列表框中显示计算机上每个可用 CD 的驱动器说明符和播放列表名称。 如果驱动器实际包含 DVD 内容,则需要 Windows XP 或更高版本。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

// Store the number of available drives.
int numDrives = player.cdromCollection.count;

// Loop through the available drives.
for (int i = 0; i < numDrives; i++)
{
    // Store the drive specifier and playlist name for this drive in a string.
    string pl = player.cdromCollection.Item(i).driveSpecifier + " ";
    pl += player.cdromCollection.Item(i).Playlist.name;

    // Add the string to a list box.
    myPlaylists.Items.Add(pl);
}

' Store the number of available drives.
Dim numDrives As Integer = player.cdromCollection.count

&#39; Loop through the available drives.
For i As Integer = 0 To (numDrives - 1)

    &#39; Store the drive specifier and playlist name for this drive in a string.
    Dim pl As String = player.cdromCollection.Item(i).driveSpecifier + &quot; &quot;
    pl += player.cdromCollection.Item(i).Playlist.name

    &#39; Add the string to a list box.
    myPlaylists.Items.Add(pl)

Next i

要求

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

另请参阅

IWMPCdrom 接口 (VB 和 C#)

IWMPCdromCollection 接口 (VB 和 C#)

IWMPCdromCollection.count (VB 和 C#)

IWMPCdromCollection.getByDriveSpecifier (VB 和 C#)

IWMPPlaylist.name (VB 和 C#)

IWMPSettings2.mediaAccessRights (VB 和 C#)

IWMPSettings2.requestMediaAccessRights (VB 和 C#)