iImage Information

I had the need to have a switch to turn read only mode for all my USB sticks (sadly only a old 128Mb one had a hardware switch). The use of SD and microSD cards with a adaptor (they both have a switch) is a option but only if your PC has a card reader. After some research i came up with a plan. And after some testing, and codeing i have made this litlle aplication that fit my needs.
Step 1How it does what it does ?
It sets in the registry a dword value to 1 for "Read-Only Mode" and 0 for "Read-Write Mode".
Path:
HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> StorageDevicePolicies
Key
WriteProtect=1 or 0
I have added 2 registry files that enable or disable that, for learnig purpose.
Here a little improvement that MAY work.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
Set this value to 4 to desactivate usb drive, then to 3 to activate again.
So, you could modify your app to:
Read only mode:
1) set to read-only
2) desactivate usb device (act like unplug)
3) activate usb device (act like re-plugging)
4) profit!
Normal mode:
1) set to normal mode (read/write)
2) desactivate usb device (act like unplug)
3) activate usb device (act like re-plugging)
4) profit!
1. Get the device ID for all usb sticks pluged (automaticaly)
2. after registry write, disale, wait 1-2 seconds and enable all usb sticks pluged
3. I gonna work on this 2 get it working :D