Last active
August 27, 2024 16:08
-
-
Save netalkGB/bb22bfc96c8cca48deb9466b3384763e to your computer and use it in GitHub Desktop.
光学ドライブのドライブレターの一覧を取得 (ドライブにディスクがない場合は除外)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <windows.h> | |
| #include <iostream> | |
| #include <string> | |
| int main() { | |
| for (int i = 0; i < 26; ++i) { | |
| TCHAR szDrive[] = { (TCHAR)('A' + i), L':', L'\\', L'\0' }; | |
| if (!GetVolumeInformation(szDrive, NULL, NULL, NULL, NULL, NULL, NULL, 0)) continue; // 真が返れば、ディスクはあるようだ | |
| if (GetDriveType(szDrive) != DRIVE_CDROM) continue; | |
| std::cout << (std::string(1, 'A' + i) + ":") << std::endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment