zoukankan      html  css  js  c++  java
  • Qt监测光驱变化(使用WM_DEVICECHANGE)

    xxx.h

     

    protected:

    bool winEvent(MSG *msg,long * result);

     

    xxx.cpp

     

    bool CBlurayTranscoderDlg::winEvent(MSG *msg,long * result)

    {

             int msgType = msg->message;  

             if(msgType == WM_DEVICECHANGE)  

             {     

                       qDebug() << "winEvent in MgFrame : WM_DEVICECHANGE" ;     

                       PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)msg->lParam;     

                       switch(msg->wParam)     

                       {

                       case DBT_DEVICEARRIVAL:        

                                if (lpdb -> dbch_devicetype == DBT_DEVTYP_VOLUME)        

                                {     

                                         PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;           

                                         if (lpdbv -> dbcv_flags & DBTF_MEDIA)           

                                         {                

                                                   /*此处可以做你想做的事*/           

                                                   qDebug() << "CD_Arrived ";            

                                         }        

                                }        

                                break;         

                       case DBT_DEVICEREMOVECOMPLETE:        

                                if (lpdb -> dbch_devicetype == DBT_DEVTYP_VOLUME)        

                                {           

                                         PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;           

                                         if (lpdbv -> dbcv_flags & DBTF_MEDIA)           

                                         {                

                                                   // 弹出光驱,此处可以做你想做的事              

                                                   qDebug() << "CD_Removed";           

                                         }        

                                }        

                                break;     

                       } // skip the rest   

             } // end of if msgType  

             return false; // let qt handle the rest

    }

    只在主窗口中实现以上代码时才可以执行.

    http://blog.chinaunix.net/uid-20718335-id-364414.html

  • 相关阅读:
    PHP 内核:foreach 是如何工作的(一)
    PHP 消息队列 Kafka 使用
    PHP7 生产环境队列 Beanstalkd 正确使用姿势
    你知道Laravel ORM 中的骚操作吗
    PHP 的 interface 有什么用处
    PHP 框架 Hyperf 实现处理超时未支付订单和延时队列
    java 浅谈web系统当中的cookie和session会话机制
    如何用charles进行https抓包
    Java实现图片按修改时间排序
    java读取文本文件内容
  • 原文地址:https://www.cnblogs.com/findumars/p/5040431.html
Copyright © 2011-2022 走看看