私の質問に基づいて仮想ドライブもインストールされている場合、実際の CD-Rom ドライブ文字を見つけるにはどうすればよいですか?
ここから得た提案ドライブが仮想か物理かを識別する方法
DeviceID 文字列に SCSI が含まれている場合に、仮想ドライブ文字のコンボ ボックスに入力したいのですが、両方の仮想ドライブをテストしましたが、それらに対して SCSI がリストされています。
提案されたリンクの例からの回答の最初の 4 文字
string driveLetter = "G";
ManagementObjectSearcher diskQuery = new ManagementObjectSearcher(String.Format("SELECT * FROM Win32_CDROMDrive WHERE Drive='{0}:'", driveLetter));
ManagementObject diskResult = diskQuery.Get().OfType<ManagementObject>().SingleOrDefault();
string deviceID = null;
if (diskResult != null)
deviceID = (string)diskResult["DeviceID"];
MessageBox.Show(deviceID);
SCSIを表示するので、このようなことができると思いました
ManagementObjectSearcher diskQuery = new ManagementObjectSearcher(String.Format("select * from Win32_CDROMDrive Where DeviceID Like '%SCSI%'"));
ManagementObject diskResult = diskQuery.Get().OfType<ManagementObject>().SingleOrDefault();
string deviceID = null;
if (diskResult != null)
deviceID = (string)diskResult["DeviceID"];
MessageBox.Show(deviceID);
ただし、機能しません。無効な操作の例外が発生します。
私がやろうとしているのはこれです
ComboBox cbVirtual = new ComboBox();
var vdrives = DriveInfo.GetDrives();
foreach (var drive in vdrives)
if (drive.DriveType == DriveType.CDRom)
{
If the deviceID string contains SCSI
{
Fill the Combo box with the drive letter/s
}
}
いくつかの助けに感謝します-乾杯。