I have a card reader ( no memory stick is inserted ).
When i insert into my compter it shows an empty drive in My Computer…
Is it possible to know whether a drive is having a media ( sorry i am not sure how to call it ) or not…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I find the suggestion of MSalters to use
IOCTL_STORAGE_CHECK_VERIFYvery good. There are a small trick in the usage ofIOCTL_STORAGE_CHECK_VERIFY. Before the usage of IOCTL code in the functionDeviceIoControlone need to open the corresponding device with respect ofCreateFilefunction:For the usage of
DeviceIoControlone can use 0 as a second parameter ofCreateFile, because we will not useReadFile,WriteFileetc functions to access the device. The implementation ofIOCTL_STORAGE_CHECK_VERIFYdo follow to some read of data requests. So to be able to useIOCTL_STORAGE_CHECK_VERIFYwithout havingERROR_ACCESS_DENIED(5) error we have to open the device as followingThere exist another version of
IOCTL_STORAGE_CHECK_VERIFY–IOCTL_STORAGE_CHECK_VERIFY2which works absolutely the same asIOCTL_STORAGE_CHECK_VERIFYbut much more quickly (see http://msdn.microsoft.com/en-us/library/ff560538.aspx). To useIOCTL_STORAGE_CHECK_VERIFY2one can open device with onlyFILE_READ_ATTRIBUTESaccess:The code which test the existence of the media in the drive can look like following