Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to differentiate a floppy drive and a USB drive in VC++?

How to differentiate a floppy drive and a USB drive in VC++?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    code663
    wrote on last edited by
    #1

    Hi, how to differentiate a floppy drive and a USB drive in VC++ , i used GetDriveType and both have REMOVABLE property , and can some one explain how exactly to use "SetupDiGetDeviceRegistryProperty" to determine whether it's USB or FLOPPY

    N J 2 Replies Last reply
    0
    • C code663

      Hi, how to differentiate a floppy drive and a USB drive in VC++ , i used GetDriveType and both have REMOVABLE property , and can some one explain how exactly to use "SetupDiGetDeviceRegistryProperty" to determine whether it's USB or FLOPPY

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      This[^] thread might help. :)

      S 1 Reply Last reply
      0
      • N Nuri Ismail

        This[^] thread might help. :)

        S Offline
        S Offline
        Subrat Patnaik
        wrote on last edited by
        #3

        you could also use windows registry entry and settings to fetch values for hardware devices. :)

        1 Reply Last reply
        0
        • C code663

          Hi, how to differentiate a floppy drive and a USB drive in VC++ , i used GetDriveType and both have REMOVABLE property , and can some one explain how exactly to use "SetupDiGetDeviceRegistryProperty" to determine whether it's USB or FLOPPY

          J Offline
          J Offline
          Jackson2010
          wrote on last edited by
          #4

          You can issue the IOCTL_STORAGE_GET_MEDIA_TYPES_EX to differentiate. Here is an example code:

          //////////////////////////////////////////

          DWORD dwOutBytes;
          HANDLE hDevice = CreateFile(_T("\\\\.\\A:"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);

          if (hDevice != INVALID_HANDLE_VALUE)
          {
          DEVICE_MEDIA_INFO dmi;
          DeviceIoControl(hDevice,
          IOCTL_STORAGE_GET_MEDIA_TYPES_EX,
          NULL, 0,
          &dmi, sizeof(dmi),
          dwOutBytes,
          NULL);

          if ((MEDIA\_TYPE)dmi.RemovableDiskInfo.MediaType == RemovableMedia)
          {
              //USB disk
          }
          else
          {
              //Floppy
          }
          

          }

          CloseHandle(hDevice);

          //////////////////////////////////////////

          Hope it is useful to you.

          Working is a happy thing! Enjoy the free partition manager.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups