一段读取MBR的简单代码!
Uses CRT, DOS;
var
buffermbr : array[ 0 .. 512 ] of byte; { Buffer for Master Boot Record }
regs : registers;
device : word;
s : string;
Procedure readpart;
begin
with regs do
begin
ah := $02; { Read sector service request }
al := $01; { Number of sectors to read }
ch := $00; { Cylinder number or track number for floppies }
cl := $01; { Sector Number, bits 6,7 -two high bits of 10 bit
cylinder number }
dh := $00; { Head Number }
dl := device; { C=80h, D=81H, etc }
es := seg( buffermbr );
bx := ofs( buffermbr );
end;
intr( $13, regs )
end;
调用示例:
begin
clrscr;
s := paramstr( 1 );
s[ 1 ] := upcase( s[ 1 ] );
if s[ 1 ] = 'C' then
begin
device := $80;
end
else
begin
device := Ord( s[ 1 ] ) - Ord( 'A' );
if device > 1 then
device := $80 + ( device - 2 );
end;
readpart;
end.