简体   繁体   English

在USB大容量存储上写入权限

[英]Write permission on usb mass storage

I want to make an usb disk write protected, I have found doing this as a solution: 我想对USB磁盘进行写保护,已找到解决方法:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies]
"WriteProtect"=dword:00000001

But this has 2 drawbacks for me: 但这对我有2个缺点:

  1. It doesn't work on a already mounted usb disk, if the mounting is prior to modifying the registry, it works though if I remove and add the disk or any other disk again. 它在已经安装的USB磁盘上不起作用,如果在修改注册表之前进行了安装,但是如果我再次删除并添加磁盘或任何其他磁盘,它仍然可以工作。

  2. This works for all usb ports. 这适用于所有USB端口。

So, what I what is to: 所以,我要做什么:

  1. Make the usb disk write protected based on the serial number(which I get in a windows service) immediately after I get the device_arrival event in my windows service. 在Windows服务中收到device_arrival事件后,立即根据序列号(在Windows服务中获得)对USB磁盘进行写保护。 I don't want to have to reinsert the usb stick for it to work. 我不想重新插入USB记忆棒以使其正常工作。

  2. And could it be possible to restrict this behaviour for specific usb disks? 是否可以限制特定USB磁盘的这种行为? I mean, If I have usb disk nr1 which I want to be write protected, and usb disk nr2 which I don't want to be write protected, could I mount them bothm on my pc at the same time with the desired write/read premssions? 我的意思是,如果我有想要被写保护的USB磁盘nr1和不想被写保护的usb磁盘nr2,我是否可以将它们都同时安装在PC上,并具有所需的写/读功能敬畏?

By the way, I want to do this in C#, and I'm working on Windows 7. 顺便说一句,我想在C#中执行此操作,并且我正在Windows 7上工作。

Don't know how valid this is but could you force an eject and remount in software? 不知道这有多有效,但是您可以强制弹出并重新安装在软件中吗?

How to programmatically unplug & replug an arbitrary USB device? 如何以编程方式拔出并重新插入任意USB设备?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM