Search code examples
cwinapidevice-driverwdk

SetupDiGetDriverInfoDetail returns ERROR_INSUFFICIENT_BUFFER


I used SetupDiGetDriverInfoDetail to retrive the details of the driver. I used the following code fragment for this. But each time I execute my exe I am getting ERROR_INSUFFICIENT_BUFFER. How to solve this?

SetupDiGetDriverInfoDetail(hDevInfo, &DeviceInfoData, &drvInfoData, &drvInfoDetail, sizeof(drvInfoDetail), NULL);

Thanks..


Solution

  • First, read Microsoft's explanation of why the SetupDiGetDriverInfoDetail function might return ERROR_INSUFFICIENT_BUFFER. Second, write code to call it twice.

    Call SetupDiGetDriverInfoDetail the first time with a pointer to a DWORD variable where you will find out how many bytes you need. Allocate memory for a sufficiently large variable and call SetupDiGetDriverInfoDetail again.