private static string _GetDevicePath(IntPtr deviceInfoSet, NativeInterface.SP_DEVICE_INTERFACE_DATA deviceInterfaceData) { var bufferSize = 0; var interfaceDetail = new NativeInterface.SP_DEVICE_INTERFACE_DETAIL_DATA { Size = IntPtr.Size == 4 ? 4 + Marshal.SystemDefaultCharSize : 8 }; NativeInterface.SetupDiGetDeviceInterfaceDetailBuffer(deviceInfoSet, ref deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero); return(NativeInterface.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, ref interfaceDetail, bufferSize, ref bufferSize, IntPtr.Zero) ? interfaceDetail.DevicePath : null); }
private static string _GetDevicePath(IntPtr deviceInfoSet, NativeInterface.SP_DEVICE_INTERFACE_DATA deviceInterfaceData) { var bufferSize = 0; var interfaceDetail = new NativeInterface.SP_DEVICE_INTERFACE_DETAIL_DATA { Size = IntPtr.Size == 4 ? 4 + Marshal.SystemDefaultCharSize : 8 }; NativeInterface.SetupDiGetDeviceInterfaceDetailBuffer(deviceInfoSet, ref deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero); return NativeInterface.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, ref interfaceDetail, bufferSize, ref bufferSize, IntPtr.Zero) ? interfaceDetail.DevicePath : null; }