Solved

How to call DOS Interrupts in delphi?

Posted on 1998-12-30
4
548 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

10 Experts available now in Live!

Get 1:1 Help Now