Link to home
Start Free TrialLog in
Avatar of VapiSoft
VapiSoft

asked on

Enum disks

Hi,
How do I enumerate (enum) the disks in a computer.
Avatar of phoffric
phoffric

Could you elaborate about what you want. An example showing usage of the enum might be useful.
Avatar of VapiSoft

ASKER

If I have disks c:, d: and e:
I want to get it in the program.
Something like EnumDisks(..)
You want to discover what drives you have? Or do you already know them, and you just want to convert enum values to strings; for example, C_DRIVE, D_DRIVE to "C:", "D:".
SOLUTION
Avatar of magicdlf
magicdlf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I want to discover what drives I have in the computer.
I thought that I will find a simple EnumDrives but I dont find it.
You have found: QueryDosDevice. See comment http:#a26117665
 
You can try using WMI's Win32_LogicalDisk class to get the list of all logical drive. Once you have the object, use Name property of this class to get the drive name.
Just loop through all possibiliteis (a .. z) and check each

TCHAR sDrive[4];
_tcscpy(sDrive, _T("A:\\"));
for(TCHAR c = _T('A'); c <= _T('Z'); c++)
{
  sDrive[0] = c;
  int ret = GetDriveType(sDrive);
}

GetDriveType
 
The GetDriveType function determines whether a disk drive is a  removable, fixed, CD-ROM, RAM disk, or network drive. UINT GetDriveType(
  LPCTSTR lpRootPathName
);
  Parameters lpRootPathName  [in] Pointer to a null-terminated string that specifies the root directory  of the disk to return information about.
A trailing backslash is required. If this parameter is NULL, the function  uses the root of the current directory. Return Values
The return value specifies the type of drive. It can be one of the following  values.    Value Meaning  DRIVE_UNKNOWN The drive type cannot be determined.  DRIVE_NO_ROOT_DIR The root path is invalid, for example, no volume is mounted at  the path.  DRIVE_REMOVABLE The drive is a type that has removable media, for example, a  floppy drive or removable hard disk.  DRIVE_FIXED The drive is a type that cannot be removed, for example, a fixed  hard drive.  DRIVE_REMOTE The drive is a remote (network) drive.  DRIVE_CDROM The drive is a CD-ROM drive.  DRIVE_RAMDISK
@evilrix: thanks.
I've pressed on the RequestAttention button. So... I do not know what to with that request.
 
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial