IWMPCdrom::driveSpecifier property

[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 driveSpecifier property gets the CD or DVD drive letter.

Syntax

public System.String driveSpecifier {get; set;}

Public ReadOnly Property driveSpecifier As System.String

Property value

A System.String that is the drive letter.

Remarks

Typically, DVD drives can play CD media, but CD drives cannot play DVD media.

This property gets a drive letter for a zero-based drive index within the range retrieved using IWMPCdromCollection.count. The value retrieved takes the form X:, where X represents the drive letter.

To retrieve the value of this property, read access to the library is required. For more information, see Library Access.

Examples

The following example uses driveSpecifier to build a string that contains a list of available CD and DVD drives and displays that string in a message box. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

// String that will contain the list of drive specifiers.
string MyDriveSpecifiers = "Drive letters found:  ";

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

// Loop through the available drives. 
for (int i = 0; i < numDrives; i++)
{
    MyDriveSpecifiers += player.cdromCollection.Item(i).driveSpecifier;
    MyDriveSpecifiers += " ";
}

// Display the list of drive specifiers in a message box.
System.Windows.Forms.MessageBox.Show(MyDriveSpecifiers);

'  String that will contain the list of drive specifiers.
Dim MyDriveSpecifiers As String = &quot;Drive letters found:  &quot;

&#39;  Store the number of available drives.
Dim numDrives = player.cdromCollection.count

&#39;  Loop through the available drives. 
For i As Integer = 0 To (numDrives - 1)
    MyDriveSpecifiers += player.cdromCollection.Item(i).driveSpecifier
    MyDriveSpecifiers += &quot; &quot;
Next i

&#39;  Display the list of drive specifiers in a message box.
System.Windows.Forms.MessageBox.Show(MyDriveSpecifiers)

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#)

IWMPCdromCollection.count (VB and C#)

IWMPSettings2.mediaAccessRights (VB and C#)

IWMPSettings2.requestMediaAccessRights (VB and C#)