IWMPCdromCollection::count 属性

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

count 属性获取系统上可用 CD 和 DVD 驱动器的数量。

语法

public System.Int32 count {get; set;}

Public ReadOnly Property count As System.Int32

属性值

一个 System.Int32,表示可用驱动器的计数。

备注

若要检索此属性的值,需要对库具有读取访问权限。 有关详细信息,请参阅 库访问

DVD 驱动器的计数与 CD 驱动器完全相同。 但是,Windows 媒体播放器 ActiveX 控件仅支持 Windows XP 或更高版本的 DVD 功能。 通常,DVD 驱动器可以播放 CD 介质,但 CD 驱动器无法播放 DVD 媒体。

示例

以下示例使用 count 在消息框中显示可用 CD 和 DVD 驱动器的数量。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

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

// Display the number of drives as a string.
System.Windows.Forms.MessageBox.Show("Number of available CD and DVD drives:  " + numDrives.ToString());

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

' Display the number of drives as a string.
System.Windows.Forms.MessageBox.Show("Number of available CD and DVD drives:  " + numDrives.ToString())

要求

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

另请参阅

IWMPCdromCollection 接口 (VB 和 C#)

IWMPSettings2.mediaAccessRights (VB 和 C#)

IWMPSettings2.requestMediaAccessRights (VB 和 C#)