又轮到我"一刀制敌了"?
这个过程可以设置paradox表一些特殊参数:
procedure RestructureTable(Table: TTable; Option, OptData: string);
var
hDb: hDBIDb;
TblDesc: CRTblDesc;
Props: CurProps;
pFDesc: FLDDesc;
begin
if Table.Active <> True then
raise EDatabaseError.Create('Table is not opened');
if Table.Exclusive <> True then
raise EDatabaseError.Create('Table must be opened exclusively');
Check(DbiGetCursorProps(Table.Handle, Props));
if StrComp(Props.szTableType, szPARADOX) <> 0 then
raise EDatabaseError.Create('Table must be of type PARADOX');
Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
Table.Close;
FillChar(TblDesc, SizeOf(TblDesc), #0);
StrPCopy(TblDesc.szTblName, Table.Tablename);
StrCopy(TblDesc.szTblType, szParadox);
pFDesc.iOffset := 0;
pFDesc.iLen := Length(OptData) + 1;
StrPCopy(pFDesc.szName, Option);
TblDesc.iOptParams := 1; // Only one optional parameter
TblDesc.pFldOptParams := @pFDesc;
TblDesc.pOptData := @OptData[1];
try
// Restructure the table with the new parameter.
Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
finally
Table.Open;
end;
end;
调用方法:
Table1.tablename:='xxxxxxx.db';
Table1.Exclusive:=True;
Table1.Open;
RestructureTable(Table1, 'LANGDRIVER', 'china');
Table1.Close;
注意调用参数必须严格按我上面的写,否则无用甚至出严重错误。