how to check if data carrier is inserted?

i googled for quite a lot of time but i haven't found anything... i'm looking for a way to check if a data carrier is inserted: i have 4 free interfaces ( I:\ J:\ ...) which are not used, and always when i want open them with the application it tells me to insert a data carrier. how can i first check if there is a data carrier, without getting an error?
Last edited on
You could try to read the directory. If your read attempt succeeds, it's there.
how? with something like fstream? newbie in this sector...
No. You need something low level to find if a hardware device is inserted without triggering the error message box, like DeviceIoControl() maybe ...
What actually happens when your data carrier is inserted? Does your existing system spot it and assign a drive letter, or do you actually have to handle that bit yourself too?

If your system hands out drive letters, you can use opendir of dirent.h functions (or Win32 equivalent) to try drive letters, and use the returned values to assess the existence or not of that drive/directory.
Last edited on
closed account (DSLq5Di1)
Assuming you are on Windows,
http://msdn.microsoft.com/en-us/library/bb762120%28VS.85%29.aspx
http://archive.msdn.microsoft.com/shellapplication (Change Notify Watcher Sample)
thanks to all... but i finally solved it by writing the info about the drives from shell to a file and reading it... not really fast but enough for my purposes...
Topic archived. No new replies allowed.