"Greg Smith" <gj*@umn.edu> wrote in
news:OY**************@TK2MSFTNGP10.phx.gbl:
Is there a way to detect how many, and what drive letters the CD/DVD
drives on a system are?
You can use Environment.GetLogicalDrives to enumerate them, and
kernel32.dll's GetDriveType to figure out what it is.
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class MyClass
{
[DllImport("kernel32.dll")]
public static extern DriveType GetDriveType( string lpRootPathName );
public enum DriveType : uint
{
DRIVE_UNKNOWN = 0,
DRIVE_NO_ROOT_DIR = 1,
DRIVE_REMOVABLE = 2,
DRIVE_FIXED = 3,
DRIVE_REMOTE = 4,
DRIVE_CDROM = 5,
DRIVE_RAMDISK = 6
}
public static void Main()
{
string[] x = Environment.GetLogicalDrives();
foreach(string y in x)
{
DriveType t = GetDriveType(y);
Console.WriteLine(y + " - " + t.ToString());
}
Console.ReadLine();
}
}
--
-mdb