Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get all the connected drives on the running machine.
- std::vector<std::string> AssiFileFinder::get_connected_drives()
- {
- std::list<std::wstring> usb_list;
- wchar_t drives[256];
- wchar_t* temp = drives;
- GetLogicalDriveStrings(256, drives);
- // Check for each drive if they are removable
- while(*temp != NULL)
- {
- const auto drive_type = GetDriveTypeW(temp);
- // Check if the drive is removable
- if(drive_type == 2 || drive_type == 3)
- {
- usb_list.emplace_back(temp);
- }
- temp += lstrlenW(temp) + 1;
- }
- std::vector<std::string> connected_drives;
- // Add drives to vector
- for (auto element : usb_list)
- {
- std::string connected_drive(element.begin(), element.end());
- connected_drives.push_back(connected_drive);
- }
- return connected_drives;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement