#include <stdio.h> bool isReady(const char cDrive) { char buf[MAX_PATH]; _snprintf(buf, sizeof(buf), "dir %c:\\ 2>&1", cDrive); FILE *f = _popen(buf, "rt"); if (f == NULL) return false; bool ready = true; for (;;) { if (fgets(buf, sizeof(buf), f) == NULL) break; if (strstr(buf, "The device is not ready") != NULL) { ready = false; break; } } fclose(f); return ready; }
Programming Tips - Windows: Exception 0x0000013 Invalid Parameters
Date: 2022nov24
Platform: Windows
Language: C/C++
Q. Windows: Exception 0x0000013 Invalid Parameters
A. I got this popup while trying to access a disk that wasn't ready.
I tried catching the exception but that didn't work.
This small routine works but is slightly slow since it shells out.