예제 #1
0
        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);
        }
예제 #2
0
        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);
        }