如何在程序中动态获得光驱状态,(光驱开着,光驱关着)~!!!!

解决方案 »

  1.   

    void CGetPassWordDlg::OnBtonGetCD() 
    {
    // my code start here
    int nDriveType;
    char *DriveName[10] = {"a:","b:","c:","d:","e:","f:","g:","h:","i:","j:"};
    int i; char pszDriveName[20];
    DWORD DriveSerial;
    DWORD MaximumComponentLength;
    DWORD FileSystemFlags;
    char pszFileSystemNameBuffer[30]; for(i=0;i<10 && nDriveType != DRIVE_CDROM ;i++)
    {
    nDriveType = ::GetDriveType(DriveName[i]); 
    }
    ::GetVolumeInformation( 
    DriveName[i-1],                // address of root directory of the file system 
    pszDriveName, // address of name of the volume 
    20,                  // length of lpVolumeNameBuffer 
    &DriveSerial, // address of volume serial number 
    &MaximumComponentLength, // address of system maximum filename length 
    &FileSystemFlags,        // address of file system flags 
    pszFileSystemNameBuffer,    // address of name of file system 
    30         // length of lpFileSystemNameBuffer 
    ); 

    UpdateData(TRUE);

    if(MaximumComponentLength > 256) 
    {
                   // 光驱中没盘
    }
             else
             {
                   // 有盘
             }......
      

  2.   

    See the thesis below, useful ,FYI :http://www.comprg.com.cn/wz048.htm
      

  3.   

    楼上,mci 不可以,我觉得在window的底层应该有所判断!!!
    希望继续讨论!!!!!111111
      

  4.   

    http://expert.csdn.net/Expert/TopicView1.asp?id=1096384
    http://expert.csdn.net/Expert/topic/1087/1087020.xml?temp=.4908563
    唉,你和我一相可怜,
    如果你知道答案,也请你好心告诉我。
      

  5.   

    直接获取好象做不到,不过可以采取一个变通的办法:
    在你的程序启动的时候,将光驱关闭,然后处理程序收到的WM_DEVICECHANGE消息
      

  6.   

    有一个ToolsOcx的控件:
    http://member.netease.com/~hxzhang/toolsocx.htm
    你可以直接使用,介绍如下(转粘):
    得到光驱的状态:short CDRomGetState();
      

  7.   

    见过吸盘式的CD吗?先锋(pioneer,北美最好的光驱品牌,国内见不到)的光驱都没有托盘,所以跟本没有什么打开、关闭的状态。标准的光驱数据接口是不提供这个状态改变事件的,但是现在的光驱有没有在IDE的定义里加上这个东西就不太清楚了。如果有将会是非常麻烦的,只能通过用汇编调用中断才可以。