IWMPCdromCollection::getByDriveSpecifier 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
getByDriveSpecifier 方法返回与特定驱动器号关联的 IWMPCdrom 接口。
语法
public IWMPCdrom getByDriveSpecifier(
System.String bstrDriveSpecifier
);
Public Function getByDriveSpecifier( _
ByVal bstrDriveSpecifier As System.String _
) As IWMPCdrom
Implements IWMPCdromCollection.getByDriveSpecifier
parameters
-
bstrDriveSpecifier [in]
-
一个 System.String ,是驱动器号,后跟冒号 (“:”) 字符。
返回值
WMPLib.IWMPCdrom 接口。
备注
驱动器号必须以 X:的形式提供,其中 X 表示驱动器号。
若要使用此方法,需要对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
以下示例使用 getByDriveSpecifier 获取 IWMPCdrom 接口,该接口对应于用户在文本框中提供的驱动器号。 然后调用 IWMPCdrom.弹出 方法以弹出指定的驱动器。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Store the drive letter provided by the user.
string driveLetter = myText.Text;
// Append a colon to the drive letter to create a valid drive specifier.
driveLetter += ":";
// Get an IWMPCdrom interface for the drive.
WMPLib.IWMPCdrom drive = player.cdromCollection.getByDriveSpecifier(driveLetter);
// Use the eject method of the IWMPCdrom interface to open the drive door.
drive.eject();
' Store the drive letter provided by the user.
Dim driveLetter As String = myText.Text
' Append a colon to the drive letter to create a valid drive specifier.
driveLetter += ":"
' Get an IWMPCdrom interface for the drive.
Dim drive As WMPLib.IWMPCdrom = player.cdromCollection.getByDriveSpecifier(driveLetter)
' Use the eject method of the IWMPCdrom interface to open the drive door.
drive.eject()
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈