views:

327

answers:

4

Friends, How to lock/unlock(software based) removable disk/drives in VB6? I need to know any specific win32 routines are there for this purpose?

A: 

Opening a file on the removable disk is the simplest way to lock the drive. This can be done with VB6's internal Open command, or by declaring the OpenFile API and calling that.

I imagine there are ways of locking the drive itself, but it is much easier to lock a file instead.

rpetrich
By just reading we cant lock the tray... You can able to lock the cd tray.
Srinivasan__
+1  A: 

Not having used this, I would say that you want to look at the win32 IOCTL_STORAGE_MEDIA_REMOVAL Control Code parameter to DeviceIoControl() which "..Enables or disables the mechanism that ejects media, for those devices possessing that locking capability..."

Peter M
@ peter M Could you please give the exact function for lock and the same for unlock here.
Srinivasan__
All I know is what is in the link that I have posted. I have never used this function myself.
Peter M
A: 

This will not be of great use to you, but simple proof if can be done there, from linux kernel 2.6 documentation.

An alternative to API, meanwhile, could be this, a software that does just that, lock/unlock CD drives.

Cheers.

Jay
A: 

Please, try this sample is the best solution:

http://vbnet.mvps.org/index.html?code/disk/deviolock.htm

Regards

d3lph1f0cu5

d3lph1f0cu5