FindFirstFile function is causing "There is no disc in the drive. Please insert a disc into drive" Error. The cause of this error is that there is no sd-card in the USB stick开发者_StackOverflow社区 and it's empty. My problem is that I have to scan all the drives for a specific directory and I cannot distinguish whether the drive is empty or not. How can I do this?
I am developing application for Windows and I am using MFC for development.
Any help would be highly appreciated.
Farooq-
I'm guessing a little, but I suspect you need to call SetErrorMode()
passing the SEM_FAILCRITICALERRORS
flag to suppress this dialog appearing. Instead FindFirstFile()
will return a failure code and you can move on to the next drive in the enumeration.
Edit: For Windows 7 and up, consider SetThreadErrorMode()
instead. That limits the effect of the mode. Also remember to restore the original mode as soon as possible.
精彩评论