Solved

How can i hideo or block access to drives?

Posted on 1998-03-08
1
212 Views
Last Modified: 2010-04-06
How Can I hide or block access to floppy drive and Cd-Rom drive throught Delphi?
0
Comment
Question by:narabe
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 20 total points
ID: 1360271
Hi narabe,

Yo, just found out too. This should it be, but haven't tried it out fully yet.

I'm going to put also in my component TCDEvents. It's freeware and maybe something just for you? Have a look at it and let me know what you think about it. You can find it at Torry's or super delphi pages...

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);
// Locking...

  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...');

// Unlocking

  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

Good luck...

Regards, Zif.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question