> I need to develop a small app to lock/unlock the floppy driver and/or
> CD-ROM in Win95 environment.
> I need some example code if it involves low-level programming.
> A direction of a component would be very useful too.
> TIA
Try this...
const
VWIN32_DIOC_DOS_IOCTL = 1;
VWIN32_DIOC_DOS_INT13 = 4;
procedure TForm1.Button1Click(Sender: TObject);
type
PDIOC_REG = ^TDIOC_Registers;
TDIOC_Registers = record
Reg_EBX, Reg_EDX, Reg_ECX, Reg_EAX,
Reg_EDI, Reg_ESI, Reg_Flags : DWORD
end;
var
I, W: dWord;
WBuffer: array[0..512 * 18] of byte;
Reg: TDIOC_Registers;
Result: Boolean;
cb: dword;
begin
Device:= CreateFile('\.vwin32',0, FILE_SHARE_READ or
FILE_SHARE_WRITE, nil, 0,
FILE_FLAG_DELETE_ON_CLOSE, 0);
reg.reg_EAX:= $440D;
reg.reg_EBX:= $0000; // BL $00 to $7F for Floppy, $80 to $FF for Hard-disk
reg.reg_ECX:= $084B;
reg.reg_EDX:= $0000;
Result:= DeviceIoControl(Device, VWIN32_DIOC_DOS_IOCTL, @reg, sizeof(reg),
@reg, sizeof(reg), cb, nil);
if ((Result = False) or ((reg.reg_Flags and $0001) = 1)) then
ShowMessage('Lock failure...');
reg.reg_EAX:= $440D;
reg.reg_EBX:= $0000; // BL $00 to $7F for Floppy, $80 to $FF for Hard-disk
reg.reg_ECX:= $086B;
reg.reg_EDX:= $0000;
Result:= DeviceIoControl(Device, VWIN32_DIOC_DOS_IOCTL, @reg, sizeof(reg),
@reg, sizeof(reg), cb, nil);
if ((Result = False) or ((reg.reg_Flags and $0001) = 1)) then
ShowMessage('Unlock failure...');
CloseHandle(Device);
end;
// See too: Interrupt 21h Function 440Dh Minor Code 6Bh Unlock Physical Volume, and
// Interrupt 21h Function 440Dh Minor Code 4Bh Lock Physical Volume in Win32.HLP |
|