Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,109 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,727 people online right now. Registration is fast and FREE... Join Now!




Program to write protect USB thumb drive?!

 
Reply to this topicStart new topic

Program to write protect USB thumb drive?!

tootypegs
9 Oct, 2007 - 01:56 AM
Post #1

D.I.C Head
**

Joined: 9 Oct, 2007
Posts: 177


My Contributions
Hi,

Basically i would like your help or if you could just point me in the right direction. I am fairly new to C++ but i have been given the task to create a program that write protects USB thumb drives. To do this i was planning on changing the registry key that enables write blocking through a simple C++. I did think this would be quite easy but boy WAS I WRONG!! I have borland C++ builder but im going round in circles. I have researched into this on the internet and visited the registry refernce site but i just cant seem to get a decent start. Can anyone give me any tips or help on how to do this? any tutorials or ANYTHING lol, im totally open for any suggestions or help. I have a tight deadline but hopefully with your help i can give this program a good go.

Thanks icon_up.gif icon_up.gif
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Program To Write Protect USB Thumb Drive?!
9 Oct, 2007 - 08:31 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Interesting challenge. I am not too sure the market is in demand for such software since most drives come with a physical mechanism for protecting write access, but I did manage to find you a C# project which implements write protection for USB. I know you wanted C++, but hopefully you can take a gander at the C# and see how they did it, so then port it over to something in C++.

Write protection for USB Drive in C#

Hopefully this proves useful. Good luck! smile.gif
User is online!Profile CardPM
+Quote Post

no2pencil
RE: Program To Write Protect USB Thumb Drive?!
9 Oct, 2007 - 09:06 AM
Post #3

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,441



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
The interesting thing on this subject, from my opinion, is that the write protection would need to take place on the USB drive, & not the computer that it is hooked into. So where would a program come into play? If you wrote a program that doesn't allow for someone to write to a device, but removed the device & took it to another machine, it could then be written to. Or is this not what you are looking to do?

I would think that you would need to format the device with ntfs or something else that can do file level permissions.

Best of luck!
User is online!Profile CardPM
+Quote Post

tootypegs
RE: Program To Write Protect USB Thumb Drive?!
9 Oct, 2007 - 11:32 PM
Post #4

D.I.C Head
**

Joined: 9 Oct, 2007
Posts: 177


My Contributions
Thanks for your help guy, appreciate it lots. Basically, it mite seem a bit useless and crazy but a little software write blocker would be quite useful for some of the tasks that i am am undertaking. I was wondering if i just tried to crawl before i can walk haha and just ask for ur advice on lil bits at a time.

Basically i have located the registry key in which i want to change

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

Can anyone point me in the direction of any information i can use to code this operation? I have already done a fair bitting of digging but i just cant seem to gather any info or tips that can help me?


User is offlineProfile CardPM
+Quote Post

nirvanarupali
RE: Program To Write Protect USB Thumb Drive?!
10 Oct, 2007 - 12:07 AM
Post #5

D.I.C Foot
Group Icon

Joined: 1 Aug, 2007
Posts: 983



Thanked: 2 times
Dream Kudos: 375
My Contributions
You are going to use an 3 API calls to accomplish this
CODE

RegOpenKeyEx(); This opens the key we want to write to
RegSetValueEx(); This sets our value
RegCloseKey();     This closes the key


User is offlineProfile CardPM
+Quote Post

toplogic
RE: Program To Write Protect USB Thumb Drive?!
15 Oct, 2007 - 09:17 PM
Post #6

New D.I.C Head
*

Joined: 15 Oct, 2007
Posts: 1


My Contributions
QUOTE(no2pencil @ 9 Oct, 2007 - 10:06 AM) *

The interesting thing on this subject, from my opinion, is that the write protection would need to take place on the USB drive, & not the computer that it is hooked into. So where would a program come into play? If you wrote a program that doesn't allow for someone to write to a device, but removed the device & took it to another machine, it could then be written to. Or is this not what you are looking to do?

I would think that you would need to format the device with ntfs or something else that can do file level permissions.

Best of luck!



Dear no2pencil
This is exactl what I am looking for
I want the write protection should take place on the USB drive, & not the computer that it is hooked into
Can you help me by telling how can this be done throuh C# or .Net
I shall be very thankful if you could help me out in achieving this
Regards
Toplogic
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:34PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month