recognizing removable media

So I have a section of code that goes like this:

1
2
3
4
ofstream myfile;
  myfile.open ("E:/info.txt");
  myfile << usrName << endl << logOn << endl << birthDate << endl << age << endl;
  myfile.close();


Instead of using drive letter E: I'd like it to just recognize a usb flash drive and save it there, no matter what drive letter it is, I know this is possible in real studio, how about C++?
I don't know for Linux or Mac. For Windows you would have an invisible top level window. That window will receive a WM_DEVICECHANGE whenever a new drive is connected or a new network drive is mapped. Read all about this message @ MSDN Online.
I don't know how I would implement this into my code
You would have to have a top-level window, at least invisible. This means that you should move from console (I guess you have a console application) to a windows application. If you still want the console, you can google up how to add a console to a windows GUI application.

If you have never programmed a windows GUI application, you need to learn about those. Try the tutorial @www.winprog.org. It is good except for the fact that it mixes data types and therefore it gives noobies a hard time when using Visual Studio 2008 and up. Just note this: To compile the samples there, either use the provided projects (already properly configured) or make sure you set your project to multibyte instead of unicode.
Topic archived. No new replies allowed.