• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 947
  • Last Modified:

Enum disks

Hi,
How do I enumerate (enum) the disks in a computer.
0
VapiSoft
Asked:
VapiSoft
  • 3
  • 3
  • 2
  • +3
3 Solutions
 
phoffricCommented:
Could you elaborate about what you want. An example showing usage of the enum might be useful.
0
 
VapiSoftAuthor Commented:
If I have disks c:, d: and e:
I want to get it in the program.
Something like EnumDisks(..)
0
 
phoffricCommented:
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:".
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
magicdlfCommented:
To get the list of available drives, use GetLogicalDrives().
see: http://www.dreamincode.net/forums/showtopic73473.htm
This article is helpful if you want to do further development:
http://www.codeproject.com/KB/static/driveinfo.aspx


0
 
pgnatyukCommented:
Try QueryDosDevice and GetDriveType or whatever yoy'll find here:
http://msdn.microsoft.com/en-us/library/aa365730(VS.85).aspx
An example: http://www.flounder.com/querydosdevice.htm
 Here is an article on CodeProject: http://www.codeproject.com/KB/winsdk/usbdisks.aspx
MSND (a bit different functions used but from the same MSDN section): http://msdn.microsoft.com/en-us/library/cc542456(VS.85).aspx
 
0
 
VapiSoftAuthor Commented:
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.
0
 
pgnatyukCommented:
You have found: QueryDosDevice. See comment http:#a26117665
 
0
 
milindsmCommented:
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.
0
 
AndyAinscowCommented:
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
0
 
pgnatyukCommented:
@evilrix: thanks.
I've pressed on the RequestAttention button. So... I do not know what to with that request.
 
0
 
VapiSoftAuthor Commented:
I gave points to magicdlf and pgnatyuk wich gave me good replies.
What do you want me to do?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now