Can someone explain technically how Windows identify the type of drive plugged into a computer?
I'm asking this question because I'm about to create a program that will only write data into a specific type of storage drive…and I'm curious how it happens behind the scenes.
Best Answer
You can get this information from two places: wmic diskdrive and wmic logicaldisk - (and of course, their wmi bindings for equivilents).
The output of wmic diskdrive - note the capability descriptions and media type
And here, the output of wmic logicaldisk - description here is what's mainly of interest.
As for where this information is from - the disks themselves should have that information in smart (from what I can tell from smartmontools, some of the values reported are different , ssd's wouldn't have spin up time, for example). On linux hdparm gives you detailed information, the same way using wmic would (but much more conveniently)
Removable vs non removable drive is set on a flag on the drive - this is actually switchable with the right tools.
In short, it asks the disk