Exemplo n.º 1
0
        internal Device(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
        {
            if (deviceClass == null)
                throw new ArgumentNullException("deviceClass");

            if (deviceInfoData == null)
                throw new ArgumentNullException("deviceInfoData");

            this.deviceClass = deviceClass;
            this.path = path; // may be null
            this.deviceInfoData = deviceInfoData;
            this.index = index;
        }
Exemplo n.º 2
0
 internal override Device CreateDevice(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
 {
     return new Volume(deviceClass, deviceInfoData, path, index);
 }
Exemplo n.º 3
0
 internal virtual Device CreateDevice(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
 {
     return new Device(deviceClass, deviceInfoData, path, index);
 }
Exemplo n.º 4
0
        internal Guid GetProperty(Native.SP_DEVINFO_DATA devData, int property, Guid defaultValue)
        {
            if (devData == null)
                throw new ArgumentNullException("devData");

            int propertyRegDataType = 0;
            int requiredSize;
            int propertyBufferSize = Marshal.SizeOf(typeof (Guid));

            IntPtr propertyBuffer = Marshal.AllocHGlobal(propertyBufferSize);
            if (
                !Native.SetupDiGetDeviceRegistryProperty(deviceInfoSet, devData, property, out propertyRegDataType, propertyBuffer, propertyBufferSize,
                                                         out requiredSize)) {
                Marshal.FreeHGlobal(propertyBuffer);
                int error = Marshal.GetLastWin32Error();
                if (error != Native.ERROR_INVALID_DATA)
                    throw new Win32Exception(error);
                return defaultValue;
            }

            var value = (Guid) Marshal.PtrToStructure(propertyBuffer, typeof (Guid));
            Marshal.FreeHGlobal(propertyBuffer);
            return value;
        }
Exemplo n.º 5
0
 internal Volume(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
     : base(deviceClass, deviceInfoData, path, index)
 {
 }