回复 4# leibin0121
指定的驱动器不存在,返回 ""(空白).
你设了条件,并没有返回空白时的处理.
你的代码只能检查"Fixed"(固定的)、 "RAMDisk"(内存盘).
仔细看看你自己的代码.
Local $i
For $i = 67 To 90
$var = DriveGetType(Chr($i) & ":\")
If $var = "Fixed" And "cdrom" Then
MsgBox(16,"Warning"," 固定磁盘和光驱")
EndIf
If $var = "RAMDisk" And "removable" Then
MsgBox(16,"Warning","移动磁盘")
Else
EndIf
Next
你的代码是这样.如果 $var的值为 "Fixed"
MsgBox(16,"Warning"," 固定磁盘和光驱")
EndIf
如果 $var的值为 "RAMDisk"
MsgBox(16,"Warning","移动磁盘")
EndIf
你是想写成这样吧?如果 $var的值为 "Fixed" 或者 $var的值为 "cdrom"
弹出消息框 MsgBox(16,"Warning"," 固定磁盘和光驱")
如果 $var的值为 "RAMDisk" 或者 $var的值为 "removable"
弹出消息框 MsgBox(16,"Warning","移动磁盘")
这样写法是不对的.
If $var = "Fixed" And "cdrom" Then
那么因该是这样写
Local $i
For $i = 67 To 90
$var = DriveGetType(Chr($i) & ":\")
If $var = "Fixed" Or $var = "cdrom" Then
MsgBox(16,"Warning"," 固定磁盘和光驱")
EndIf
If $var = "RAMDisk" Or $var = "removable" Then
MsgBox(16,"Warning","移动磁盘")
Else
EndIf
Next
你想检测C到Z的驱动器状态,那就再加个判断.
If $var = "Unknown" Then
MsgBox(16, "Warning", "???")
EndIf
If $var = "" Then
MsgBox(16, "Warning", "???")
EndIf
遇到这样问题时,看看帮助查一下各个函数的意思,你把它翻译成中文,自然就明白哪里错了. |