Example #1
0
        private static string GetBusReportedDeviceDescription(IntPtr deviceInfoSet, ref NativeMethods.SpDevinfoData devinfoData)
        {
            var descriptionBuffer = new byte[1024];

            if (Environment.OSVersion.Version.Major > 5)
            {
                ulong propertyType = 0;
                var   requiredSize = 0;

                var _continue = NativeMethods.SetupDiGetDeviceProperty(deviceInfoSet,
                                                                       ref devinfoData,
                                                                       ref NativeMethods.DevpkeyDeviceBusReportedDeviceDesc,
                                                                       ref propertyType,
                                                                       descriptionBuffer,
                                                                       descriptionBuffer.Length,
                                                                       ref requiredSize,
                                                                       0);

                if (_continue)
                {
                    return(descriptionBuffer.ToUtf16String());
                }
            }
            return(null);
        }
Example #2
0
        private static NativeMethods.SpDevinfoData CreateDeviceInfoData()
        {
            var deviceInfoData = new NativeMethods.SpDevinfoData();

            deviceInfoData.cbSize    = Marshal.SizeOf(deviceInfoData);
            deviceInfoData.DevInst   = 0;
            deviceInfoData.ClassGuid = Guid.Empty;
            deviceInfoData.Reserved  = IntPtr.Zero;

            return(deviceInfoData);
        }
Example #3
0
        private static NativeMethods.SpDevinfoData CreateDeviceInfoData()
        {
            var deviceInfoData = new NativeMethods.SpDevinfoData();

            deviceInfoData.cbSize = Marshal.SizeOf(deviceInfoData);
            deviceInfoData.DevInst = 0;
            deviceInfoData.ClassGuid = Guid.Empty;
            deviceInfoData.Reserved = IntPtr.Zero;

            return deviceInfoData;
        }
Example #4
0
        private static string GetDeviceDescription(IntPtr deviceInfoSet, ref NativeMethods.SpDevinfoData devinfoData)
        {
            var descriptionBuffer = new byte[1024];

            var requiredSize = 0;
            var type         = 0;

            NativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSet,
                                                           ref devinfoData,
                                                           NativeMethods.SpdrpDevicedesc,
                                                           ref type,
                                                           descriptionBuffer,
                                                           descriptionBuffer.Length,
                                                           ref requiredSize);

            return(descriptionBuffer.ToUtf8String());
        }