コード例 #1
0
ファイル: Device.cs プロジェクト: srushti/azazel
        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;
        }
コード例 #2
0
ファイル: DeviceClass.cs プロジェクト: srushti/azazel
        internal Native.SP_DEVINFO_DATA GetInfo(int dnDevInst)
        {
            var sb = new StringBuilder(1024);
            int hr = Native.CM_Get_Device_ID(dnDevInst, sb, sb.Capacity, 0);
            if (hr != 0)
                throw new Win32Exception(hr);

            var devData = new Native.SP_DEVINFO_DATA();
            devData.cbSize = Marshal.SizeOf(typeof (Native.SP_DEVINFO_DATA));
            if (!Native.SetupDiOpenDeviceInfo(deviceInfoSet, sb.ToString(), IntPtr.Zero, 0, devData))
                throw new Win32Exception(Marshal.GetLastWin32Error());

            return devData;
        }