Solved

How to call DOS Interrupts in delphi?

Posted on 1998-12-30
4
564 Views
Last Modified: 2010-04-04
Hi,
  I want to read and write data from a
  specific cluster in a floppy. Is there
  any way other that calling interrupts.
  I would like to know how to call DOS
  Interrupts from Delphi.


  Is there any way other than calling
  Interrupts for reading data from a specific
  cluster in a Floppy.
     
 
  I would be much greatful if u can help
  me out in solving this problem or any
  related web sites.  

regards
   jagan
0
Comment
Question by:rjagan
[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
4 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1353900
You'll have to call DeviceIOControl. It's quite difficult. If you've Delphi 2 or 3, please open the win32.hlp file and look in the index for something like "Calling DeviceIOControl on Win95". In the win32.hlp shipped with Delphi4 these pages are gone, don't know why...

Regards, Madshi.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1353901
It's quite difficult if possible to do the task u want... Similar question has already been asked and the guy had to do it in TP and call his DOS app in order for this to work...
0
 
LVL 2

Expert Comment

by:ivi
ID: 1353902
jagan, what is your Delphi version (16 bit or 32 bit)?
What is operating system? 3.1? 95/98? NT?
0
 

Accepted Solution

by:
tothpaul earned 20 total points
ID: 1353903
windows 95 allow DeviceIoControl for floppy disk; but not for hard drive. To access hard drive sectors you need to write a .vxd driver (impossible with Delphi) or to use a 16bits DLL (Delphi 1)  using INT 31h (DPMI DOS Call).

Type
 TRegs=record
  edi,esi,bp,Reserved,ebx,edx,ecx,eax:longint;
  Flags,es,ds,fs,gs,ip,cs,sp,ss:word;
 end;

Function ReadSector(Drive,Head,Track,Sector,Count:word; Var Data):boolean;
 Var
  Regs:TRegs;
  Dpmi:boolean;
  Buff:longint;
  ARegs:pointer;
 begin
 {The return value contains a paragraph-segment value in its high-order word and
  a selector in its low-order word.}
  Buff:=GlobalDosAlloc(512);

  with Regs do begin
   eax:=$0200+Count; { BIOS read, "Count" sector  }
   edx:=Head shl 8 + Drive;
   ecx:=(Lo(Track) shl 8)+Hi(Track) shl 6+Sector;
   es :=HiWord(Buff); { Segment of sector buffer }
   ebx:=$0000;        { Offset of sector buffer }
  end;
  ARegs:=@Regs;

  asm  { Realmode Interrupt }
   mov ax,$0300      { DPMI Simulate Real Mode int }
   mov bl,$13        { Interrupt to simulate       }
   mov bh,$01
   xor cx,cx
   les di,ARegs
   int 31h
   mov al,False
   jc  @Done
    mov al,True
   @Done:
   mov Dpmi,al
  end;

  if Dpmi then begin
   if odd(Regs.Flags) then begin
    showMessage('Unable to read sector');
    ReadSector:=false;
   end else begin
    Move(Ptr(LoWord(Buff),0)^,Data,512);
    ReadSector:=true;
   end;
  end else begin
   showmessage('Dpmi error');
   ReadSector:=false;
  end;

  GlobalDosFree(LoWord(Buff));
 end;


0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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