Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Created December 4, 2017 15:28
Show Gist options
  • Select an option

  • Save Trass3r/b1121e31ff5770976d9c42d11b016642 to your computer and use it in GitHub Desktop.

Select an option

Save Trass3r/b1121e31ff5770976d9c42d11b016642 to your computer and use it in GitHub Desktop.
private static IEnumerable<SP_DEVINFO_DATA> GetDeviceInfoData(SafeDeviceInfoSetHandle devInfoSet)
{
var did = default(SP_DEVINFO_DATA);
uint didSize = (uint)Marshal.SizeOf(did);
did.cbSize = didSize;
uint index = 0;
while (SetupDiEnumDeviceInfo(devInfoSet, index, ref did))
{
yield return did;
++index;
did = default(SP_DEVINFO_DATA);
did.cbSize = didSize;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment