A SetupDI* error that doesn't make sense.
It's been a while but I'm getting back into my USB HiD programming now. Here's the piece of code I'm trying to troubleshoot:
the parametric variables are defined as followed:
SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref anInterface, IntPtr.Zero, 0, ref buffersize, IntPtr.Zero);
errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
statusLabel.Text += "\nSetupDiGetDeviceInterfaceDetail failed because " + errorMessage.ToString();
THe function in question is invoked as:
anInterface = new SP_DEVICE_INTERFACE_DATA();
anInterface.cbSize = (uint)Marshal.SizeOf(anInterface);
anInterface.InterfaceClassGuid = Guid.Empty;
anInterface.Reserved = IntPtr.Zero;
anInterface.Flags = 0;
public IntPtr deviceInfoSet;
I keep getting the error message: setupDiGetDeviceInterfaceDetail failed because The parameter is incorrect.
[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Boolean SetupDiGetDeviceInterfaceDetail(IntPtr hDevInfo, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData,
uint deviceInterfaceDetailDataSize, ref uint requiredSize,
I am at a loss as to what is the cause of this error. Can anyone shed a light on this please or hint? Any comment will be welcomed.