// JP opened flex table

Click to See Complete Forum and Search --> : Write protect USB mapped drive


Kannan.in
February 27th, 2007, 10:23 AM
How to write protect USB mapped drive?

I need to know the set of API's (and if possible the pseudocode) to make a drive read only (write protect) any drive, especially USB mass storage device.
I tried modifying ACE in ACL in SD and applying on folder... this seems to work but not with a USB mapped drive.

Any help would be highly appreciated!

Thanks,
Kannan

Kannan.in
March 1st, 2007, 08:54 AM
I dont know if there are any VC++ solutions for the query(there should be!!!)... but I managed to find one alternative... find that below.

Windows XP Service Pack 2 (SP2) introduces a new registry subkey that lets you mark USB-based storage devices such as memory sticks as read-only devices. This is a useful security capability that can prevent users from copying data from their systems and taking that data offsite via a USB device. To enable the USB write protection, perform the following steps:

1. Start the registry editor (regedit.exe).
2. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies subkey. (Create the StorageDevicePolicies subkey if it doesn't already exist.)
3. From the Edit menu, select New, DWORD Value.
4. Type the name WriteProtect and press Enter.
5. Double-click the new value and set it to 1. Click OK.
6. Close the registry editor.
7. Restart the computer.

To disable this change, you can either set WriteProtect to 0 or delete it.

Y0rkieP
March 1st, 2007, 03:27 PM
Thats good if you wanted to set it manually but to set the registry in C++, that would be more of a challenge, though it looks possible.

Wondering such things I went to Yahoo.com and looked for something like "change windows registry c++". I did find a couple of sites on this, but the code seems quite complex.

I am only a newbie with winapi and no expert on c++, to me is seemed complex and stopped there. maybe I'll look again when I know more. If you wanted you could try the search that I did...

MrViggy
March 1st, 2007, 05:46 PM
I dont know if there are any VC++ solutions for the query(there should be!!!)... but I managed to find one alternative... find that below.

Windows XP Service Pack 2 (SP2) introduces a new registry subkey that lets you mark USB-based storage devices such as memory sticks as read-only devices. This is a useful security capability that can prevent users from copying data from their systems and taking that data offsite via a USB device. To enable the USB write protection, perform the following steps:

1. Start the registry editor (regedit.exe).
2. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies subkey. (Create the StorageDevicePolicies subkey if it doesn't already exist.)
3. From the Edit menu, select New, DWORD Value.
4. Type the name WriteProtect and press Enter.
5. Double-click the new value and set it to 1. Click OK.
6. Close the registry editor.
7. Restart the computer.

To disable this change, you can either set WriteProtect to 0 or delete it.
Well, you can also change the registry using C++:

http://msdn2.microsoft.com/en-us/library/ms724875.aspx

Viggy

Kannan.in
March 2nd, 2007, 12:52 AM
I guess manipulating registry entries via VC++ code is not a problem... the problem here is - how to control access to removable USB drives, by choosing the access mask passed as a parameter to the unknown API (if exists...)

Can any VC++ system programming expert respond to this query please? Thanks in advance for the time spent on this.

Thanks.

//JP added flex table