实际上,在DBF文件的第28个字节表明了DBF文件是否有索引文件,因此,只要把DBF文件的第28个字节修改一下即可。
procedure TForm1.Button1Click(Sender: TObject);
var
f: file of byte;
b: byte;
begin
if OpenDialog1.execute then
begin
assignFile(f, OpenDialog1.FileName);
reset(f);
seek(f, 28);
b := RadioGroup1.ItemIndex; {0 = no MDX; 1 = use MDX}
write(f, b);
closefile(f);
end;
OpenDialog1.FileName := '*.dbf'; {reset the filter}
end;