public static extern bool SetupDiGetDeviceInterfaceDetail( IntPtr lpDeviceInfoSet, ref HIDNativeMethods.DeviceInterfaceData oInterfaceData, ref HIDNativeMethods.DeviceInterfaceDetailData oDetailData, uint nDeviceInterfaceDetailDataSize, ref uint nRequiredSize, IntPtr lpDeviceInfoData);
private static string GetDevicePath( IntPtr hInfoSet, ref HIDNativeMethods.DeviceInterfaceData oInterface) { uint nRequiredSize = 0; if (!HIDNativeMethods.SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0U, ref nRequiredSize, IntPtr.Zero)) { Log.s(LOG_LEVEL.ERROR, "HID_Manager|GetDevicePath : SetupDiGetDeviceInterfaceDetail failed"); } HIDNativeMethods.DeviceInterfaceDetailData oDetailData = new HIDNativeMethods.DeviceInterfaceDetailData(); oDetailData.Size = Marshal.SizeOf(typeof(IntPtr)) == 8 ? 8 : 5; if (!HIDNativeMethods.SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, ref oDetailData, nRequiredSize, ref nRequiredSize, IntPtr.Zero)) { Log.s(LOG_LEVEL.ERROR, "HID_Manager|GetDevicePath : SetupDiGetDeviceInterfaceDetail failed"); } return(oDetailData.DevicePath); }