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:
 SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref anInterface, IntPtr.Zero, 0, ref buffersize, IntPtr.Zero);
                if (!result)
                    errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
                    statusLabel.Text += "\nSetupDiGetDeviceInterfaceDetail failed because " + errorMessage.ToString();
the parametric variables are defined as followed:
anInterface = new SP_DEVICE_INTERFACE_DATA();
        anInterface.cbSize = (uint)Marshal.SizeOf(anInterface);
        anInterface.InterfaceClassGuid = Guid.Empty;
        anInterface.Reserved = IntPtr.Zero;
        anInterface.Flags = 0;
uint buffersize;
public IntPtr deviceInfoSet;
THe function in question is invoked as:
[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern Boolean SetupDiGetDeviceInterfaceDetail(IntPtr hDevInfo, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData,
                                                                     IntPtr deviceInterfaceDetailData,
                                                                     uint deviceInterfaceDetailDataSize, ref uint requiredSize,
                                                                     IntPtr deviceInfoData);
I keep getting the error message: setupDiGetDeviceInterfaceDetail failed because The parameter is incorrect.
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.