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

后端 未结 5 1567
无人及你
无人及你 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

    A few pieces of information can be gathered without too much trouble:

    • Use GetDriveType to find the first removeable drive, test if writeable media exists (which will largely rule out CD drives). May also want to look at further strings that are available when you query the drive information via win32.
    • Use libusb to see where the first storage class USB device is (will likely be a flash or hard drive)
    • This C# article points towards win32 disk drive classes you might be able to tap into.

    Post your answer here when you find it!

    -Adam

提交回复
热议问题