Func _Drive_Optical_Type( $Drive, $Computer = ".")
If DriveGetType($Drive) <> "CDROM" Then Return SetError(1)
Local $oRtn = ""
$Drive = StringUpper($Drive)
$Obj_CD = ObjGet("winmgmts:\" & $Computer & "\root\cimv2")
$Items = $Obj_CD.ExecQuery("Select * from Win32_CDROMDrive WHERE Id = '" & $Drive & Chr(39))
For $Item in $Items
$oRtn = StringMid($Item.DeviceID, StringInStr($Item.DeviceID, "_")+1)
If StringInStr($oRtn, "Virtual") Then
$oRtn = StringMid($oRtn, StringInStr($oRtn, "Virtual"))
$oRtn = StringReplace($oRtn, "_", " ", 1)
$oRtn = StringLeft($oRtn, 15)
Else
$oRtn = StringLeft($oRtn, StringInStr($oRtn, "_") -1)
EndIf
Next
If $oRtn = "" Then Return SetError(1)
Return $oRtn
EndFunc ;<==> _Drive_Optical_Type()
官网上找的,蛋蛋不会wmi |