IWMPCdromCollection::getByDriveSpecifier method

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The getByDriveSpecifier method returns an IWMPCdrom interface associated with a particular drive letter.

Syntax

public IWMPCdrom getByDriveSpecifier(
  System.String bstrDriveSpecifier
);

Public Function getByDriveSpecifier( _
  ByVal bstrDriveSpecifier As System.String _
) As IWMPCdrom
Implements IWMPCdromCollection.getByDriveSpecifier

Parameters

bstrDriveSpecifier [in]

A System.String that is the drive letter followed by a colon (":") character.

Return value

A WMPLib.IWMPCdrom interface.

Remarks

Drive letters must be given in the form X:, where X represents the drive letter.

To use this method, read access to the library is required. For more information, see Library Access.

Examples

The following example uses getByDriveSpecifier to get the IWMPCdrom interface that corresponds to a drive letter provided by the user in a text box. The IWMPCdrom.eject method is then called to eject the specified drive. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named 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()

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

See also

IWMPCdrom Interface (VB and C#)

IWMPCdrom.eject (VB and C#)

IWMPCdromCollection Interface (VB and C#)

IWMPSettings2.mediaAccessRights (VB and C#)

IWMPSettings2.requestMediaAccessRights (VB and C#)