How do I detected whether a hard drive is connected via USB?

后端 未结 5 1545
无人及你
无人及你 2021-01-01 06:52

I am trying to write a little backup program for friends and family and want it to be as simple to use a possible. I don\'t want to have to ask the user where to backup thei

5条回答
  •  伪装坚强ぢ
    2021-01-01 07:10

    You need to use RegisterDeviceNotification function. Here is some pointers about how to do it. And one more sample code

    You can enumerate all mass storage devices using this sample. In General look for SetupDiXXX api's.

    Please note that taking in consideration dynamic nature of usb devices, using notification mechanism is mandatory IMHO. You might find your self analyzing device that already detached or missing new device that just arrived.

提交回复
热议问题