コード例 #1
0
ファイル: CiteLib.cs プロジェクト: ewin66/VideoManager
        private void devNotifier_OnDeviceNotify(object sender, DeviceNotifyEventArgs e)
        {
            EventType eventType = e.EventType;
            //e.DeviceType;
            IUsbDeviceNotifyInfo device = e.Device;
            IVolumeNotifyInfo    volume = e.Volume;

            if ((int)eventType == 32768 && volume != null)
            {
                this.USBDrive = volume.Letter;
                this.Callback(this, new CmdCiteEventArgs(DEV_ACTIONS.IS_USB));
            }
            if ((int)eventType == 32768)
            {
                if (device.ClassGuid.Equals(Guid.Parse("a5dcbf10-6530-11d2-901f-00c04fb951ed")))
                {
                    this.MountDevice();
                }
                if (!string.IsNullOrEmpty(volume.Letter))
                {
                    this.USBDrive = volume.Letter;
                }
            }
            if ((int)eventType == 32772)
            {
                this.IsConnected = false;
                this.Callback(this, new CmdCiteEventArgs(DEV_ACTIONS.DISCONNECTED));
            }
        }
コード例 #2
0
        /// <summary>
        /// 热插拔设备拔出
        /// </summary>
        /// <param name="deviceInfo"></param>
        public void DeviceRemove(IUsbDeviceNotifyInfo deviceInfo)
        {
            try
            {
                string msg = "检测到拔出设备!";
                if (richTextBox1.InvokeRequired)
                {
                    // 当一个控件的InvokeRequired属性值为真时,说明有一个创建它以外的线程想访问它
                    Action <string> actionDelegate = (x) => { this.richTextBox1.AppendText(msg); };
                    // 或者
                    // Action<string> actionDelegate = delegate(string txt) { this.label2.Text = txt; };
                    this.richTextBox1.Invoke(actionDelegate, msg);
                }
                else
                {
                    this.richTextBox1.AppendText(msg);
                }

                SetTextBoxValue2(deviceInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("处理设备移除异常" + "{0}异常信息:{1}", FileUtils.NEW_LINE_SPACE, ex));
            }
        }
コード例 #3
0
 /// <summary>
 /// 结果赋值2
 /// </summary>
 private void SetTextBoxValue2(IUsbDeviceNotifyInfo info)
 {
     if (progressBar1.InvokeRequired)
     {
         SetTextBox2 setpos = new SetTextBox2(SetTextBoxValue2);
         this.Invoke(setpos, new object[] { info });
     }
     else
     {
         richTextBox1.AppendText("设备安装类GUID   ClassGuid    " + info.ClassGuid + FileUtils.NEW_LINE_SPACE);
         richTextBox1.AppendText("设备名称         Name         " + info.Name + FileUtils.NEW_LINE_SPACE);
         richTextBox1.AppendText("产品编号         ProductID    " + info.IdProduct + FileUtils.NEW_LINE_SPACE);
         richTextBox1.AppendText("供应商标识       VendorID     " + info.IdVendor + FileUtils.NEW_LINE_SPACE);
         richTextBox1.AppendText(FileUtils.NEW_LINE_SPACE);
     }
 }
コード例 #4
0
 public DeviceID(IUsbDeviceNotifyInfo info)
 {
     Product = info.IdProduct;
     Vendor  = info.IdVendor;
     Serial  = info.SerialNumber;
 }