That's any body now how to lock removable media using C#, OS that using is Windows XP.

Thanks for help :D

i know that you wanted C# help but leave it.
i did a script using a batch, working like a charm.
i got 500 "media locked" computers on my company.
i attched 2 zip files.
in each file there are 3 .REG files.

Lock.zip

lock_USB.reg - Locking just usb mass storage device (disk on key and other storage devices) it isn't locking usb mouse ,printers, scanners etc.
lock_CDROM.reg - Locking CD-ROM
lock_Floppy.reg - Locking Floppy disk

UnLock.zip

unlock_USB.reg - disables the lock on the usb
unlock_CDROM.reg - disables the lock on the cdrom
unlock_Floppy.reg - disables the lock on the floppy disk

just import the files into the registry and walla !

the cd_rom and floppy disk locks needs to restart in order th apply.
You can import the .REG files into the windows registry using batch file (to do a statup script on GP or any other way):

regedit /s [name of the reg files]

exmaple:

regedit /s lock_USB.reg

You can either change the registry keys using c# or any other way.

that's it, GL.

p.s
if you need any more help, just email me: wildog@gmail.com.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.