锁闭光驱的问题(就是锁闭光驱面板上的弹出/关闭按钮)

gnuljf 2007-08-08 09:35:25
刚在这里http://topic.csdn.net/t/20030221/13/1451340.html找到一个代码,在VC2005、windows2003下测试通过。
但是在查找MSDN时,发现有这么个东西:
The IOCTL_STORAGE_MEDIA_REMOVAL control code enables or disables the mechanism that ejects media, for those devices possessing that locking capability.
The IOCTL_STORAGE_EJECTION_CONTROL control code enables or disables the mechanism that ejects media. Disabling the mechanism locks the drive.
前面的代码中是用IOCTL_STORAGE_MEDIA_REMOVAL实现光驱的锁定、解锁的,以我相当贫乏的英文水平看上面2段MSDN说明,IOCTL_STORAGE_EJECTION_CONTROL与IOCTL_STORAGE_MEDIA_REMOVAL的作用好像是一样的吧?可是为何使用IOCTL_STORAGE_EJECTION_CONTROL却不能达到相同的目的——DeviceIoControl总是返回FALSE
...全文
208 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
gnuljf 2008-01-17
我靠,还是没人解答啊,算了,结贴
回复
gnuljf 2007-12-03
继续顶上去
回复
gnuljf 2007-10-12
上去,咋就没人帮忙看看呢?
回复
ribut9225 2007-10-02
帮顶
偶也是金山受害者
回复
lubf 2007-10-01
回复
gnuljf 2007-08-18
唉,可怜啊,没人关注
回复
gnuljf 2007-08-10
以下是从MSDN Online中找来的,谁能帮忙解释一下

IOCTL_STORAGE_EJECTION_CONTROL

Operation
Locks the device to prevent removal of the media. If the driver can prevent the media from being removed while the drive is in use, the driver disables or enables the mechanism that ejects media, thereby locking the drive. A caller must open the device with FILE_READ_ATTRIBUTES to send this request.

Unlike IOCTL_STORAGE_MEDIA_REMOVAL, the driver tracks IOCTL_STORAGE_EJECTION_CONTROL requests by caller and ignores unlock requests for which it has not received a lock request from the same caller, thereby preventing other callers from unlocking the drive.

A driver for a removable-media device - can support this IOCTL must do the following:

Keep a lock count, tagged by caller, in the device object extension.
Keep the lock count per physical device.
When called with this IOCTL, if the flag to prevent removing the media is set, increment the count; if the flag is clear and the driver has previously received a lock request from the same caller, decrement the count.
Prevent removal of the media unless all lock counts are zero.
Under normal circumstances, the caller who locked the device using IOCTL_STORAGE_EJECTION_CONTROL, unlocks the device by sending IOCTL_STORAGE_EJECTION_CONTROL again with Irp->AssociatedIrp.SystemBuffer set to a boolean value of FALSE. However, sometimes the caller fails to unlock the device properly.

To ensure that media removal locks are released properly, the class driver keeps track of callers who lock the media with IOCTL_STORAGE_EJECTION_CONTROL. If the caller terminates without unlocking the device, the class driver unlocks the device.


Input
The buffer at Irp->AssociatedIrp.SystemBuffer contains a Boolean value, with TRUE indicating that the driver should lock the media in the drive.

Output
None

I/O Status Block
The Information field is set to zero. The Status field is set to STATUS_SUCCESS, or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_NO_MEDIA_IN_DEVICE, or STATUS_DEVICE_NOT_CONNECTED.

Requirements
Headers: Defined in ntddstor.h. Include ntddstor.h.
回复
gnuljf 2007-08-10
以下是从MSDN Online中找来的,谁能帮忙解释一下

IOCTL_STORAGE_EJECTION_CONTROL

Operation
Locks the device to prevent removal of the media. If the driver can prevent the media from being removed while the drive is in use, the driver disables or enables the mechanism that ejects media, thereby locking the drive. A caller must open the device with FILE_READ_ATTRIBUTES to send this request.

Unlike IOCTL_STORAGE_MEDIA_REMOVAL, the driver tracks IOCTL_STORAGE_EJECTION_CONTROL requests by caller and ignores unlock requests for which it has not received a lock request from the same caller, thereby preventing other callers from unlocking the drive.

A driver for a removable-media device - can support this IOCTL must do the following:

Keep a lock count, tagged by caller, in the device object extension.
Keep the lock count per physical device.
When called with this IOCTL, if the flag to prevent removing the media is set, increment the count; if the flag is clear and the driver has previously received a lock request from the same caller, decrement the count.
Prevent removal of the media unless all lock counts are zero.
Under normal circumstances, the caller who locked the device using IOCTL_STORAGE_EJECTION_CONTROL, unlocks the device by sending IOCTL_STORAGE_EJECTION_CONTROL again with Irp->AssociatedIrp.SystemBuffer set to a boolean value of FALSE. However, sometimes the caller fails to unlock the device properly.

To ensure that media removal locks are released properly, the class driver keeps track of callers who lock the media with IOCTL_STORAGE_EJECTION_CONTROL. If the caller terminates without unlocking the device, the class driver unlocks the device.


Input
The buffer at Irp->AssociatedIrp.SystemBuffer contains a Boolean value, with TRUE indicating that the driver should lock the media in the drive.

Output
None

I/O Status Block
The Information field is set to zero. The Status field is set to STATUS_SUCCESS, or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_NO_MEDIA_IN_DEVICE, or STATUS_DEVICE_NOT_CONNECTED.

Requirements
Headers: Defined in ntddstor.h. Include ntddstor.h.
回复
marrco2005 2007-08-08
mark
回复
gnuljf 2007-08-08
汗,没人来……
自己顶一下
回复
相关推荐
发帖
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2007-08-08 09:35
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……