怎样判断usb外设是否连接(100分)

  • 主题发起人 主题发起人 analyst
  • 开始时间 开始时间
A

analyst

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样判断usb外设是否连接
 
不太容易,如果是简单的存储卡还可以 ,通过GetDriveType 获取可移动设备<br>要是usb鼠标,光驱 ,软驱 ,摄像头 或是特殊的外挂设备!!!<br><br>result = GetDriveType(drive);<br>&nbsp; &nbsp; <br>&nbsp; &nbsp; if (result == DRIVE_REMOVABLE)<br>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; "可移动设备" ;<br>&nbsp; &nbsp; else if (result == DRIVE_FIXED)<br>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; "硬盘";<br>&nbsp; &nbsp; else if (result == DRIVE_REMOTE)<br>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; "网络驱动器" ;<br>&nbsp; &nbsp; else if (result == DRIVE_CDROM )<br>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; " 光驱";<br>&nbsp; &nbsp; else if (result == DRIVE_RAMDISK)<br>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; "Ram Disk";<br>&nbsp; &nbsp; else if (result == DRIVE_UNKNOWN)<br>&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; "未知的设备";
 
后退
顶部