Solved

How to call DOS Interrupts in delphi?

Posted on 1998-12-30
4
549 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

864 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now