Hi hope everyone is doing well!
I got a task to do and I have no idea how to complete this!
I need to list all USB devices currently connected and also have listeners updating if any new devices are connected or disconnected!
The language is c++ and I'm using Visual Studio
I made something already however it does not list my connected phone. here is the current code that I got from another post and edited a bit:
#include <iomanip>
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
int main()
{
char VolumeName[MAX_PATH + 1];
char DriveLetter[] = "A:\\";
for (char count = 'A'; count <= 'Z'; ++count)
{
DriveLetter[0] = count;
if (GetVolumeInformation(DriveLetter, VolumeName, MAX_PATH + 1, NULL, NULL, NULL, NULL, 0) != FALSE)
if (count == 'F') {
cout << DriveLetter << "....." << VolumeName << endl;
}
}
}
I have already looked at how to do it with libusb and I do not understand a thing! The library is in C and I do not know how to do C and I'm pretty new at c++ too Also I don't know how to add that library to my existing project.
Also tried pololu Libusb (LIBUSBP) however that I do not understand how to build.
Also tried win32 API and it's just too complicated!
If you could do this task for me I would be grateful please post the code If someone can please just give me some good instructions.
Thank you!