private string GetInterfacePath(ref NativeApi.SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, DeviceInfoHandle DeviceHandle) { int requiredSize = 0; NativeApi.SetupDiGetDeviceInterfaceDetail(DeviceHandle, ref DeviceInterfaceData, IntPtr.Zero, 0, ref requiredSize, IntPtr.Zero); IntPtr DetailDataBuffer = Marshal.AllocHGlobal(requiredSize); Marshal.WriteInt32(DetailDataBuffer, 4 + Marshal.SystemDefaultCharSize); NativeApi.SetupDiGetDeviceInterfaceDetail(DeviceHandle, ref DeviceInterfaceData, DetailDataBuffer, requiredSize, ref requiredSize, IntPtr.Zero); IntPtr pDevPath = new IntPtr(DetailDataBuffer.ToInt32() + 4); String devPath = Marshal.PtrToStringAuto(pDevPath); Marshal.FreeHGlobal(DetailDataBuffer); return devPath; }