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

  • 相关阅读:
    我的SWT与数字图像处理总结(1)—重点Image类的介绍
    我的SWT与数字图像处理总结(2)—使用JFreeChart生成灰度直方图
    使用Wiz编写和发布博客园(cnblogs)博客
    RCP之病人信息系统开发总结(2):项目结构分析和重要类分析
    Java与XML(一):采用DOM操作XML文件
    Java实例开发0502 简单的HTTP服务器端
    RCP之病人信息系统开发总结(1):数据库设计
    我的SWT与数字图像处理总结(3)—SWT如何得到图像某个位置的像素值和相应的RGB的值
    对象的保存和载入
    Java与XML(二):使用Dom4j 操作 XML 文件
  • 原文地址:https://www.cnblogs.com/findumars/p/5040431.html
Copyright © 2011-2022 走看看