Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I need to change entire pen drive memory as Read Only in C language in Windows. We can done this by updating the registry value, i.e by changing the WriteProtect value from 0 to 1 in the below registry path,
HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\StorageDevicePolicies.

But if I do like this, it will update for all the pen drive which are plugged in the computer and also I have to change the computer registry setting where ever I go and plugged the pen drive in the computer. Is there any way to make the pen drive as Read Only by changing either the pen drive settings or MBR structure of the pen drive or any other way.

Please help me from this.

Thanks & Regards
Mohan
Posted

1 solution

Hi Mohanraj,

You can do this with help of intrrupt handling.

Int 21/AH=40h,

Int 21/AH=40h, is for Write disk operation. By using this you can make one exe that will execute on after insertion of pendrive into system and that will handle the write operation intrrupt of your disk.
 
Share this answer
 
Comments
Mohanraj Sam 23-Feb-11 7:06am    
Hi Laxmikant,
Thank for your immediate reply. Using Int 21/AH=40h seems assembler code, I want to do in C language how can I implement interrupt related code in C. And also another doubt will it make pen drive to write protect.

Please help me

Thanks & Regards
Mohan
LaxmikantYadav 23-Feb-11 7:21am    
Hi Mohanraj,
You can use asm block in c
asm
{
// your asm code will go here
}

And for handling the disk write intrrupt you have to google it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900