Adding TreeView to display our devices.
2 using System.Runtime.InteropServices;
6 internal sealed partial class DeviceManagement
8 internal static class NativeMethods
11 // API declarations relating to device management (SetupDixxx and
12 // RegisterDeviceNotification functions).
17 internal const Int32 DIGCF_PRESENT = 2;
18 internal const Int32 DIGCF_DEVICEINTERFACE = 0X10;
20 internal struct SP_DEVICE_INTERFACE_DATA
22 internal Int32 cbSize;
23 internal Guid InterfaceClassGuid;
25 internal IntPtr Reserved;
28 internal struct SP_DEVICE_INTERFACE_DETAIL_DATA
30 internal Int32 cbSize;
31 internal String DevicePath;
34 internal struct SP_DEVINFO_DATA
36 internal Int32 cbSize;
37 internal Guid ClassGuid;
38 internal Int32 DevInst;
39 internal Int32 Reserved;
42 [DllImport("setupapi.dll", SetLastError = true)]
43 internal static extern IntPtr SetupDiCreateDeviceInfoList(ref Guid ClassGuid, IntPtr hwndParent);
45 [DllImport("setupapi.dll", SetLastError = true)]
46 internal static extern Int32 SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);
48 [DllImport("setupapi.dll", SetLastError = true)]
49 internal static extern Boolean SetupDiEnumDeviceInterfaces(IntPtr DeviceInfoSet, IntPtr DeviceInfoData, ref Guid InterfaceClassGuid, Int32 MemberIndex, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
51 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
52 internal static extern IntPtr SetupDiGetClassDevs(ref Guid ClassGuid, IntPtr Enumerator, IntPtr hwndParent, Int32 Flags);
54 [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
55 internal static extern Boolean SetupDiGetDeviceInterfaceDetail(IntPtr DeviceInfoSet, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IntPtr DeviceInterfaceDetailData, Int32 DeviceInterfaceDetailDataSize, ref Int32 RequiredSize, IntPtr DeviceInfoData);