retrieving cd and usb drives by name

Hey all,
how do i retrieve the names(string) of all the cd drives and usb drives available?
for example if my cd/usb is named "Pencil( D: )" i want the name "Pencil" to be retrieved.
Thanks in advanced.
Isn't that just the volume name
Yes the volume name, but how do i retrive a list of array with all the volume/drive names?
I don't know of a particular windows system call that will retrieve them all at the same time - but
you can use the getVolumeInformation function to get them one at a time in a loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <windows.h>
using namespace std;

int main()
{

    char VolumeName[MAX_PATH+1];
    char DriveLetter[] = "A:\\";

    for (char count = 'A'; count <= 'Z'; ++count)
    {
        DriveLetter[0] = count;

        if (GetVolumeInformation(DriveLetter,VolumeName,MAX_PATH+1,NULL,NULL,NULL,NULL,0) != FALSE)
         cout << DriveLetter << "....." << VolumeName << endl;
    }
    
   return 0;
}
Topic archived. No new replies allowed.