laufwerk überprüfen
-
wie kann ich mit C++(winapi oder mfc) überprüfen, ob ein (cd-)laufwerk offen oder zu ist ?
-
Ich kann Dir nur sagen, wie man das Laufwerk auf/zu macht:
#include <windows.h> #include <tchar.h> #include <stdio.h> int _tmain() { DWORD dwBytes; HANDLE hCdRom = CreateFile(_T("\\\\.\\M:"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (hCdRom == INVALID_HANDLE_VALUE) { _tprintf(_T("Error: %x"), GetLastError()); return 1; } // Open the door: DeviceIoControl(hCdRom, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &dwBytes, NULL); Sleep(1000); // Close the door: DeviceIoControl(hCdRom, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &dwBytes, NULL); CloseHandle(hCdRom); }