public static DeviceInterfaceDetailData? Run(IntPtr deviceInfoSet, DeviceInterfaceData deviceInterfaceData) { var bufferSize = 0; var interfaceDetail = new DeviceInterfaceDetailData { Size = IntPtr.Size == 4 ? 4 + Marshal.SystemDefaultCharSize : 8 }; SetupDiGetDeviceInterfaceDetailBuffer(deviceInfoSet, ref deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero); if (SetupDiGetDeviceInterfaceDetailMethod( deviceInfoSet, ref deviceInterfaceData, ref interfaceDetail, bufferSize, ref bufferSize, IntPtr.Zero)) return interfaceDetail; else return null; }
static internal extern bool SetupDiGetDeviceInterfaceDetailMethod(IntPtr deviceInfoSet, ref DeviceInterfaceData deviceInterfaceData, ref DeviceInterfaceDetailData deviceInterfaceDetailData, int deviceInterfaceDetailDataSize, ref int requiredSize, IntPtr deviceInfoData);