在它說螺紋:
的ErrorLevel:
-1無效的驅動器號。
-2既不是CD/DVD驅動器,也不是USB大容量存儲設備。
-3彈出失敗。請參閱A_LastError(範圍1 - 13)至identify the reason。最常見的將是A_LastError = 6這是
PNP_VetoOutstandingOpen
請求的操作因未解決的打開句柄而被拒絕。
所以,我要說,這應該做的工作:
USB_ERROR_LIST := [ "The specified operation was rejected for an unknown reason."
, "The device does not support the specified PnP operation."
, "The specified operation cannot be completed because of a pending close operation."
, "A Microsoft Win32 application vetoed the specified operation."
, "A Win32 service vetoed the specified operation."
, "The requested operation was rejected because of outstanding open handles."
, "The device supports the specified operation, but the device rejected the operation."
, "The driver supports the specified operation, but the driver rejected the operation."
, "The device does not support the specified operation."
, "There is insufficient power to perform the requested operation."
, "The device cannot be disabled."
, "The driver does not support the specified PnP operation."
, "The caller has insufficient privileges to complete the operation." ]
#vk4A::
Eject("D:")
If (ErrorLevel = -1)
MsgBox, Invalid drive letter.
Else If (ErrorLevel = -2)
MsgBox, Neither a CD/DVD drive, nor a USB Mass Storage device.
Else If (ErrorLevel = -3) {
MsgBox, % "Eject failed:`n" USB_ERROR_LIST[A_LastError]
} Else {
MsgBox, The USB device can now be safely removed from the computer.
}
Return
什麼是在這些情況下的ErrorLevel的值是多少? – 2501
好的,感謝Forivin,我現在明白,使用語法'MsgBox,我的消息沒有必要的引號符號'顯示消息。在每個返回位置之前,我已經添加了4條消息,第一條有意義的是'MsgBox,看起來像沒有E驅動器。「和其他人進行進一步調查。現在我理解了AHK的語法,但仍然不知道ErrorLevel是什麼(或如何使用它)。我猜如果最後一個'返回'已經到達,彈出成功完成了,但我會測試一下。 – YakovL