Reputation: 276
I keep getting the Windows error 87 while calling the SetupDiGetDeviceInterfaceDetail (https://msdn.microsoft.com/en-us/library/ff551120.aspx), I keep getting the error even when I switch all the optional parameters to NULL, but I use the two first parameters in another function which works, so I don't understand what's incorrect about them.
HDEVINFO hdiInfo = SetupDiGetClassDevsW(&guid, NULL, NULL, 0x12);
SP_DEVICE_INTERFACE_DATA hidDevIData = SP_DEVICE_INTERFACE_DATA();
hidDevIData.cbSize = sizeof(hidDevIData);
bool isValid = SetupDiEnumDeviceInterfaces(hdiInfo, 0, &guid, i, &hidDevIData);
if (isValid)
{
DWORD dwLength;
PSP_DEVICE_INTERFACE_DETAIL_DATA hidDevIDetailData = PSP_DEVICE_INTERFACE_DETAIL_DATA();
hidDevIData.cbSize = 8;
hidDevIDetailData = new SP_DEVICE_INTERFACE_DETAIL_DATA();
hidDevIDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
SetupDiGetDeviceInterfaceDetail(hdiInfo, &hidDevIData, NULL, 0, &dwLength, NULL); //ERROR 87 : ERROR_INVALID_PARAMETER
}
I really don't know which parameter could be incorrect, as all the previous functions returns true (so the GUID is valid for example).
Upvotes: 2
Views: 1761
Reputation: 276
For those struggling with the same issue, you just have to put the cbSize to sizeof(object):
hidDevIData.cbSize = sizeof(hidDevIData);
hidDevIDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
Upvotes: 1