Find an external drive.

Hi, I am writing a program and I have hit a little snag. I need it to detect if there is a flash drive/floppy disk in A:, F:, G:, H:,and or :I. I found the command, but I can't figure out what to do with it. Any help will be appreciated :)

I have this so far...:
1
2
3
4
5
6
7
8
9
10
#include "Windows.h"
#include <iostream>

using namespace std;

int main()
{
DWORD WINAPI GetLogicalDrives(void);

}


I can't figure out what to do with it to build an if statement off of.
Last edited on
GetLogicalDrives returns a bitmask. To see if a drive is available you have to check a coresponding bit.

if, for example, you want to check the F drive write
1
2
DWORD drives = GetLogicalDrives();
if(drives & (1 << 6)) //do whatever you need 


if you don't understand what is a bitmask, or how to check bits, read http://en.wikipedia.org/wiki/Mask_(computing)

Hope this helps
I'm getting [Linker error] undefined reference to `_Z16GetLogicalDrivesv@0' with that... What header do i need to use with it? I'm using
1
2
3
#include "Windows.h"
#include <iostream>
#include "WinBase.h" 
Shouldn't this be in the "Windows Programming" section?
Yeah probably... I never claimed to be the brightest person =P
Topic archived. No new replies allowed.