2

Is there a Rust module or crate that provides a way to iterate over the removable drives that are attached to a Windows machine? I am running an embedded version of Windows 7 x64. The drives I want to detect are USB-connected flash-drives.

I am primarily a C# developer with C/C++ experience in the distant past, and am new to Rust and it is still seeming a bit opaque to me, so sorry for the newbie question. I am not seeing this in the Crates.io nor in the std::fs module.

I need something such as a vector of the attached removable drives (or a vector of objects each of which represents a drive plus some way to get the properties of that drive, specifically it's drive-letter and whether it is removable).

Thank you in advance for your time and help!

James Hurst
  • 147
  • 10
  • 3
    https://crates.io/crates/winrt https://crates.io/crates/winapi https://crates.io/crates/windows-acl ? You will not find anything like that in the std. – Stargateur Jan 14 '19 at 04:03
  • EVERYTHING above binary could be interpreted as a software library. SO needs to update its guidelines. – AriesConnolly Jul 17 '23 at 09:13

1 Answers1

3

There are some crates available that helps you to achieve this issue and mentioned in comments like followings:

If you do not want to depend on third party crates, you can make a call to windows itself and run the following call and get the output of it:

wmic logicaldisk where drivetype=2 get deviceid, volumename, description

You can make a windows command call via this reference

Also this Question can be helpful.

Akiner Alkan
  • 6,145
  • 3
  • 32
  • 68