How do I find out what's wrong with the device info set returned? I'm re-writing my code again and I'm still hitting the same stumbling block.
deviceInfoSet = SetupDiGetClassDevs(ref tGuid, 0, IntPtr.Zero, (uint)SetupDiFlags.DIGCF_PRESENT );
if (deviceInfoSet.ToInt32() == INVALID_DEVICE_HANDLE)
{
int errCode = Marshal.GetLastWin32Error();
errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
statusLabel.Text += "Invalid deviceinfoset returned: " + errCode + " => " + errorMessage + ".";
}
The above code doesn't cause any errors but when I use the code below:
result = true;
while (result)
{
result = SetupDiEnumDeviceInterfaces(deviceInfoSet, IntPtr.Zero, ref tGuid, Index, ref anInterface);
if (!result)
{
int errCode = Marshal.GetLastWin32Error();
errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
statusLabel.Text += "\nSetDiEnumDeviceInterface Error: " + errCode + " => " + errorMessage + ".";
break;
}
Index++;
}
to try and access the device info set list, error code 259 (No more data is available) is returned. I am at a loss as to what I'm doing wrong.