var dbe:_DBEngine;
dbs:database;
ret:Recordset;
i:integer;
begin
dbe:=coDBengine.Create;
dbs:=dbe.opendatabase('C:/My Documents/test.mdb',false,false,'');
ret:=dbs.OpenTable('test',false);
for i:=0 to ret.Indexes.Count-1 do
if ret.indexes.item.primary then //如果该索引的primary为true
caption:=ret.indexes.item.name; //那么该索引就是主键