检测可移动驱动器(例如USB闪存驱动器),C / C ++ [英] Detect removable drive (e.g. USB flash drive) C/C++

查看:237
本文介绍了检测可移动驱动器(例如USB闪存驱动器),C / C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以检测时,可移动磁盘驱动器连接到系统(DIS)?如何获得安装路径(对于Linux)和驱动器盘符(视窗)?

How can I detect when a removable disk drive is (dis)connected to the system? How to get the mount path (for Linux) and the drive letter (for windows)?

编辑:有没有一种方法来检测当前连接的设备。

Is there a way to detect the currently connected devices?

推荐答案

有关Windows中,API的 RegisterDeviceNotification 将让你知道当添加一个USB设备。有关卷的信息在 DEV_BROADCAST_VOLUME结构中给出。在 dbcv_unitmask 给人的驱动器号。

For Windows, the API RegisterDeviceNotification will let you know when a USB device is added. The information about the volume is given in the DEV_BROADCAST_VOLUME structure. The dbcv_unitmask gives the drive letter.

这篇关于检测可移动驱动器(例如USB闪存驱动器),C / C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆