Question

Is there some way to distinguish following two folders using C++ Builder code?

  1. folder of USB flash drive
  2. folder of SDcard (SDHC)

I am using C++ Builder XE4. Using the C++ Builder, I wonder I can make software to distinguish the above two folders.

I describe the problem below.

I have a note book computer which has USB connector and SD card connector. I would like to save some file into the folder of SD card. But if there is no SD card mounted, on the other hand there is some USB flash drive mounted, it should not write the file into USB flash drive by mistake. So I would like to distinguish (recognize) the SD card and the USB flash drive folders.

I would like to know some keywords on these to investigate further through the internet by myself.

Was it helpful?

Solution

Use WMI query:

This query gives you all drives (contains sdcards):

SELECT DeviceID FROM WIN32_DiskDrive

This query gives you all HardDisks:

SELECT DeviceID FROM WIN32_DiskDrive where interfacetype='IDE'

This query gives you all USB drives (does not contain sdcards):

SELECT DeviceID FROM WIN32_DiskDrive where interfacetype='USB'

Then you should associate DeviceID (like "\\.\PHYSICALDRIVE1") property to drive letter (like D:\) which it can be subject of a new question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top