This code snippet is originally from the former WinAPI site www.winapi.net
If you want to know, if the user inserted a medium like a disk or a CD into the drive, use this code:
#include <windows.h> #include <shlwapi.h> // uDrive: // 0 - A:\ // 1 - B:\ // 2 - C:\ // etc. BOOL IsDriveReady(UINT uDrive) { TCHAR szRootPathName[32]; UINT uErrorMode; BOOL bRet; PathBuildRoot(szRootPathName, uDrive); uErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); bRet = GetVolumeInformation(szRootPathName, NULL, 0, NULL, NULL, NULL, NULL, 0); SetErrorMode(uErrorMode); return(bRet); }