| 40 | static bool l_Debug; |
| 41 | |
| 42 | static int check_drives(std::vector<drive>& vDrives, std::vector<std::wstring>& vExclude_Drives) |
| 43 | { |
| 44 | DWORD dwResult, dwSize = 0, dwVolumePathNamesLen = MAX_PATH + 1; |
| 45 | WCHAR szLogicalDrives[1024], szVolumeName[MAX_PATH], *szVolumePathNames = NULL; |
| 46 | HANDLE hVolume = NULL; |
| 47 | std::wstring wsLogicalDrives; |
| 48 | size_t volumeNameEnd = 0; |
| 49 | |
| 50 | std::set<std::wstring> sDrives; |
| 51 | |
| 52 | if (l_Debug) |
| 53 | std::wcout << "Getting logic drive string (includes network drives)\n"; |
| 54 | |
| 55 | dwResult = GetLogicalDriveStrings(MAX_PATH, szLogicalDrives); |
| 56 | if (dwResult > MAX_PATH) |
| 57 | goto die; |
| 58 | if (l_Debug) |
| 59 | std::wcout << "Splitting string into single drive names\n"; |
| 60 | |
| 61 | LPTSTR szSingleDrive = szLogicalDrives; |
| 62 | while (*szSingleDrive) { |
| 63 | std::wstring drname = szSingleDrive; |
| 64 | sDrives.insert(drname); |
| 65 | szSingleDrive += wcslen(szSingleDrive) + 1; |
| 66 | if (l_Debug) |
| 67 | std::wcout << "Got: " << drname << '\n'; |
| 68 | } |
| 69 | |
| 70 | if (l_Debug) |
| 71 | std::wcout << "Getting volume mountpoints (includes NTFS folders)\n" |
| 72 | << "Getting first volume\n"; |
| 73 | |
| 74 | hVolume = FindFirstVolume(szVolumeName, MAX_PATH); |
| 75 | if (hVolume == INVALID_HANDLE_VALUE) |
| 76 | goto die; |
| 77 | |
| 78 | if (l_Debug) |
| 79 | std::wcout << "Traversing through list of drives\n"; |
| 80 | |
| 81 | while (GetLastError() != ERROR_NO_MORE_FILES) { |
| 82 | if (l_Debug) |
| 83 | std::wcout << "Path name for " << szVolumeName << "= \""; |
| 84 | volumeNameEnd = wcslen(szVolumeName) - 1; |
| 85 | szVolumePathNames = new WCHAR[dwVolumePathNamesLen]; |
| 86 | |
| 87 | while (!GetVolumePathNamesForVolumeName(szVolumeName, szVolumePathNames, dwVolumePathNamesLen, |
| 88 | &dwVolumePathNamesLen)) { |
| 89 | if (GetLastError() != ERROR_MORE_DATA) |
| 90 | break; |
| 91 | delete[] szVolumePathNames; |
| 92 | szVolumePathNames = new WCHAR[dwVolumePathNamesLen]; |
| 93 | |
| 94 | } |
| 95 | if (l_Debug) |
| 96 | std::wcout << szVolumePathNames << "\"\n"; |
| 97 | |
| 98 | sDrives.insert(std::wstring(szVolumePathNames)); |
| 99 | FindNextVolume(hVolume, szVolumeName, MAX_PATH); |