I also cannot reproduce using GUID_DEVINTERFACE_USB_HUB on Windows 11 (OS Build 22621.819) because GUID_DEVINTERFACE_USB4_ROOT_DRD is not available.
Following is the code.
#include <Windows.h>
#include <SetupAPI.h>
//#include <initguid.h>
//#include <Usbiodef.h>
const GUID GUID_DEVINTERFACE_USB_HUB{ 0xf18a0e88, 0xc30c, 0x11d0, 0x88, 0x15, 0x00, 0xa0, 0xc9, 0x06, 0xbe, 0xd8 };
#pragma comment(lib, "SetupAPI.lib")
void EnumerateUsb4HostCtrl()
{
LPGUID Guid = nullptr;
HDEVINFO DeviceInfo = nullptr;
DWORD Index = 0;
BOOL Result = FALSE;
BYTE Buf[512]{};
PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData;
SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
SP_DEVINFO_DATA DeviceInfoData;
DWORD dwSize;
//LogDebug(__func__);
Guid = (LPGUID)&GUID_DEVINTERFACE_USB_HUB;
DeviceInfo = SetupDiGetClassDevs(Guid, NULL, NULL,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (DeviceInfo == INVALID_HANDLE_VALUE)
return;
DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;
DeviceInterfaceData.cbSize = sizeof(DeviceInterfaceData);
while (TRUE) {
Result = SetupDiEnumDeviceInterfaces(DeviceInfo, NULL,
Guid, Index, &DeviceInterfaceData);
if (!Result)
break;
dwSize = 0;
SetupDiGetDeviceInterfaceDetail(DeviceInfo,
&DeviceInterfaceData, NULL, 0, &dwSize, NULL);
if (dwSize != 0 && dwSize <= sizeof(Buf)) {
DeviceInterfaceDetailData->cbSize = sizeof(*DeviceInterfaceDetailData); // 5 Bytes!
ZeroMemory((PVOID)&DeviceInfoData, sizeof(DeviceInfoData));
DeviceInfoData.cbSize = sizeof(DeviceInfoData);
Result =
SetupDiGetDeviceInterfaceDetail(DeviceInfo, &
DeviceInterfaceData, DeviceInterfaceDetailData,
dwSize, &dwSize,
&DeviceInfoData);
//LogDebug("Path: %ls", DeviceInterfaceDetailData->DevicePath);
}
Index++;
}
SetupDiDestroyDeviceInfoList(DeviceInfo);
return;
}
int main()
{
EnumerateUsb4HostCtrl();
return 0;
}