Solved

How can i hideo or block access to drives?

Posted on 1998-03-08
1
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

632 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