Problems with using the SetupDiGetClassDevs interface On Windows Server 2016

鸿 徐 0 Reputation points
2023-12-15T07:07:46.6433333+00:00

Background of the problem:

  1. We use the SetupDiGetClassDevs (&Guid_DEVINTERFACE-STOAGEPORT, NULL, NULL, DIGCF-PRESENT | DIGCF-DEVICEINTERFACE) interface to enumerate the interfaces of storage class devices.
  2. Then, based on the handle, we further obtain the device path to select our own raid card (currently, there are three devices that can be listed, including two Sata AHCI controllers and our raid card).

Now we run the script pressure test and find that the SetupDiGetClassDevs interface returns an error (the probability is small, and the next call will be successful in a few seconds). The error code is 6 (The Handle is invalid). Please ask:

  1. When will this interface report this error code?
  2. I understand that even if the RAID card is not connected, this interface should still list the two Sata AHCI controllers of the system and not report invalid handles?
Windows development | Windows API - Win32
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.