private string GetBusReportedDeviceDescription(SafeDevInfoHandle deviceInfoSet, SP_DEVINFO_DATA devinfoData) { var descriptionBuffer = new byte[1024]; string resultString = string.Empty; if (Environment.OSVersion.Version.Major > 5) { ulong propertyType = 0; var requiredSize = 0; var devPropKey = new DEVPROPKEY(); var result = NativeMethods.SetupDiGetDeviceProperty( deviceInfoSet, devinfoData, devPropKey, ref propertyType, descriptionBuffer, descriptionBuffer.Length, ref requiredSize, 0); if (result) { resultString = DescriptionEncoding.GetString(descriptionBuffer).TrimEnd('\0'); } } return(resultString); }
private string GetDeviceDescription(SafeDevInfoHandle deviceInfoSet, SP_DEVINFO_DATA devinfoData) { var descriptionBuffer = new byte[1024]; string resultString = string.Empty; var requiredSize = 0; var type = 0; var result = NativeMethods.SetupDiGetDeviceRegistryProperty( deviceInfoSet, devinfoData, NativeMethods.SPDRP_DEVICEDESC, ref type, descriptionBuffer, descriptionBuffer.Length, ref requiredSize); if (result) { Encoding.GetEncodings(); resultString = DescriptionEncoding.GetString(descriptionBuffer).TrimEnd('\0'); } return(resultString); }