Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 581
  • Last Modified:

How to call DOS Interrupts in delphi?

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
rjagan
Asked:
rjagan
1 Solution
 
MadshiCommented:
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
 
viktornetCommented:
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
 
iviCommented:
jagan, what is your Delphi version (16 bit or 32 bit)?
What is operating system? 3.1? 95/98? NT?
0
 
tothpaulCommented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now