Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Detecting removable hard drive

Posted on 2007-08-09
Medium Priority
Last Modified: 2013-11-25
How can I tall, using MS Visual C++ code, that a harddrive (F:, for instance) is removable (USB flash, for instance) or not?
Question by:olegsp

Expert Comment

ID: 19667703
Its simple:o)
well maybe not quite
you need to use SetupDiXXX class of functions

use SetupDiGetClassDevs to enumerate devices of certain class
examine content of
devguid.h    // Device guids
setupapi.h   // SetupDiXXX
header files

if that will help - here is MS knowledge base sample on how to enumerate CD-ROM drives and their properties

This should give you basic idea - or will scare you off  :o)

Ask me if you need further help

Accepted Solution

olegdasha earned 200 total points
ID: 19770883
UINT drivetype;
      switch(::GetDriveType(DrivePath)) \\ e.g., DrivePath="F:\\"
      case 0: // The drive type cannot be determined.
      case 1: // The root directory does not exist.
            drivetype = 1;
      case DRIVE_REMOVABLE: // The drive can be removed from the drive.
            drivetype = 2;
      case DRIVE_CDROM: // The drive is a CD-ROM drive.
      case DRIVE_FIXED: // The disk cannot be removed from the drive.
            drivetype = 3;
      case DRIVE_REMOTE: // The drive is a remote (network) drive.
            drivetype = 4;
      case DRIVE_RAMDISK: // The drive is a RAM disk.
            drivetype = 5;

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As hardware bugs go, this is a strange one! I upgraded a laptop in December 2011 with a 512GB Crucial m4 2.5-inch/9.5mm SATA Solid State Drive (SSD), Crucial part number CT512M4SSD2: http://www.crucial.com/store/partspecs.aspx?IMODULE=CT512M4SSD2 …
In this article you will get to know about pros and cons of storage drives HDD, SSD and SSHD.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question