I am trying to understand a WinUsb Microsoft example. There is next code:
int _tmain(int argc, _TCHAR* argv[])
{
GUID guidDeviceInterface = OSR_DEVICE_INTERFACE; //in the INF file
HANDLE hDeviceHandle = INVALID_HANDLE_VALUE;
WINUSB_INTERFACE_HANDLE hWinUSBHandle = INVALID_HANDLE_VALUE;
...some other variables...
bResult = GetDeviceHandle(guidDeviceInterface, &hDeviceHandle);
bResult = GetWinUSBHandle(hDeviceHandle, &hWinUSBHandle);
...some interesting actions with hWinUSBHandle. For example...
bResult = ReadFromBulkEndpoint(hWinUSBHandle, &PipeID.PipeInId, cbSize);
system("PAUSE");
done:
CloseHandle(hDeviceHandle);
WinUsb_Free(hWinUSBHandle);
return 0;
}
But the OSR_DEVICE_INTERFACE constant occurs only one time in the whole example with a kind of self-evidence.
If I know the VID/PID of my USB device and the target endpoint, can I get the guidDeviceInterface with such code:
deviceInfoSet = SetupDiCreateDeviceInfoList(&GUID_DEVCLASS_USB, NULL);
allDevices = SetupDiGetClassDevsExA(NULL, NULL, NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES, deviceInfoSet, NULL, NULL);
for(devIndex = 0; SetupDiGetDeviceInfo(allDevices, devIndex, &deviceInfo);devIndex++)
{
SetupDiGetDeviceInstanceIdA(deviceInfoSet, &deviceInfo, devId, 1024, &devIdLen);
if(...the VID/PID equality condition...)
{
...getting the OSR_DEVICE_INTERFACE...
}
}
If yes, what is the condition and what is the right action for getting guidDeviceInterface?