SetupDiEnumDeviceInterfaces (setupapi)
Last changed: -24.135.125.153

.
Summary
TODO - a short description

C# Signature:

[DllImport(@"setupapi.dll", CharSet=CharSet.Auto, SetLastError = true)]
public static extern Boolean SetupDiEnumDeviceInterfaces(
   IntPtr hDevInfo,
   ref SP_DEVINFO_DATA devInfo,
   ref Guid interfaceClassGuid,
   UInt32 memberIndex,
   ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData
);

VB Signature:

Declare Function SetupDiEnumDeviceInterfaces Lib "setupapi.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

    [StructLayout(LayoutKind.Sequential)]
    public struct SP_DEVINFO_DATA
    {
        public uint cbSize;
        public Guid ClassGuid;
        public uint DevInst;
        public IntPtr Reserved;
    }

//You need to create a structure for the deviceInterfaceData like this....

    public struct SP_DEVICE_INTERFACE_DATA
    {
        public int cbSize;
        public Guid InterfaceClassGuid;
        public int Flags;
        public IntPtr RESERVED;
    }

//Then initialize the cbSize value like this in your calling method

SP_DEVICE_INTERFACE_DATA devData = new SP_DEVICE_INTERFACE_DATA();

devData.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(devData);

// failure to do so will always return false (which is the value you'll also get if the device is not connected)

// Here's what the call looks like...

bool result = Win32Calls.SetupDiEnumDeviceInterfaces(ipDeviceHndl, iLU, ref DeviceGUID, 0, ref devData);

// The DeviceGUID parameter will be device dependant. Look in the Manufacturer's sdk or api for the correct guid for your device

Sample Code:

class Win32Calls
    {
    [DllImport(@"setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
    public static extern IntPtr SetupDiGetClassDevs(ref Guid classGuid, IntPtr enumerator, IntPtr hwndParent, UInt32 flags);
    [DllImport(@"setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
    public static extern Boolean SetupDiEnumDeviceInterfaces(IntPtr hDevInfo, IntPtr devInfo, ref Guid interfaceClassGuid, UInt32 memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData);

    }

Documentation